-
Notifications
You must be signed in to change notification settings - Fork 31
Examples: Fix compiling issues and imports, closes #69 #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9d2e672
Examples: Fix some compiling issues and imports
dlesnoff 4aca9d8
Add ^ operator as decorator of pow
dlesnoff 480c6be
Fix rc_leftfactorials.nim
dlesnoff 77d91fb
Remove slow computation from rc_godtheinteger.nim example
dlesnoff 9fdb0ae
Order variables in examples/pidigits.nim
dlesnoff 07c53fa
Revert "Add ^ operator as decorator of pow"
dlesnoff 4b5da37
Simplify rc_pow.nim
dlesnoff f350553
Added requested changes
dlesnoff a18c0be
Fix rc_paraffins again
dlesnoff 13f1455
Merge branch 'master' into fixExamples
dlesnoff e1bad82
Fix pidigits examples with toSignedInt
dlesnoff 38329c0
Merge with master, delete rc_modexp
dlesnoff ef2560d
Fix links and remove modinv from elliptic.nim
dlesnoff 3caeaf4
Remove unnecessary const initialization
dlesnoff b09b354
Unify pidigits.nim examples
dlesnoff b650ed0
Fuse pidigits ideas : no argument prints indefinitely
dlesnoff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
path = "$projectPath/../src" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# This example includes an infinite loop that has to be interrupted by Ctrl+C | ||
import bigints | ||
|
||
const one = 1.initBigInt | ||
var i = 0.initBigInt | ||
while true: | ||
i += 1 | ||
i += one | ||
echo i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,37 @@ | ||
import iterutils, bigints | ||
import bigints | ||
|
||
proc lfact: iterator: BigInt = | ||
result = iterator: BigInt = | ||
yield 0.initBigInt | ||
var | ||
fact = 1.initBigInt | ||
sum = 0.initBigInt | ||
n = 1.initBigInt | ||
while true: | ||
sum += fact | ||
fact *= n | ||
n += 1 | ||
yield sum | ||
const | ||
one = 1.initBigInt | ||
zero = 0.initBigInt | ||
|
||
echo "first 11:" | ||
for i in lfact().slice(last = 10): | ||
echo " ", i | ||
iterator lfact: BigInt = | ||
yield zero | ||
var | ||
fact = one | ||
sum = zero | ||
n = one | ||
while true: | ||
sum += fact | ||
fact *= n | ||
n += one | ||
yield sum | ||
|
||
echo "20 through 110 (inclusive) by tens:" | ||
for i in lfact().slice(20, 110, 10): | ||
echo " ", i | ||
var i = 0 | ||
for n in lfact(): | ||
if i == 0: | ||
echo "first 11:" | ||
if i == 20: | ||
echo "20 through 110 (inclusive) by tens:" | ||
if i == 1000: | ||
echo "Digits in 1,000 through 10,000 (inclusive) by thousands:" | ||
|
||
if i <= 10: | ||
echo i, ": ", n | ||
elif i <= 110 and i mod 10 == 0: | ||
echo i, ": ", n | ||
elif i >= 1000 and i <= 10_000 and i mod 1000 == 0: | ||
echo i, ": ", ($n).len | ||
elif i > 10_000: | ||
break | ||
inc i | ||
|
||
echo "Digits in 1,000 through 10,000 (inclusive) by thousands:" | ||
for i in lfact().slice(1_000, 10_000, 1_000): | ||
echo " ", ($i).len |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example can not be rewritten as long as we have not defined a way to convert a BigInt into an int, see issue #72. Type cast does not do the same thing, it interprets the BigInt as an int ! So the first limb is understood as the 2’s complement representation of another number. Thanks @konsumlamm for the explanation. Same for examples/rc_pidigits.nim