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
| iterator foobar: int = | |
| yield 1 | |
| yield 2 | |
| yield 3 | |
| for i in foobar(): | |
| 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
| proc split_string(str): auto = | |
| result = iterator: string = | |
| var start = 0 | |
| for i in 0..str.high: | |
| if str[i] == ' ': | |
| yield str[start..i] | |
| start = i+1 | |
| yield str[start..str.high] | |
| var c = split_string("Hello World") |
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
| /* Generated by Nim Compiler v0.10.3 */ | |
| /* (c) 2015 Andreas Rumpf */ | |
| /* The generated code is subject to the original license. */ | |
| /* Compiled for: Linux, amd64, gcc */ | |
| /* Command for C compiler: | |
| gcc -c -w -O3 -fno-strict-aliasing -I/media/nim/lib -o /home/deen/nimcache/asd.o /home/deen/nimcache/asd.c */ | |
| #define NIM_INTBITS 64 | |
| #include "nimbase.h" | |
| #include <stdio.h> |
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
| total executions of each stack trace: | |
| Entry: 1/418 Calls: 913/483 = 1.9e+02% [sum: 913; 913/483 = 1.9e+02%] | |
| newObjRC1 3001/483 = 6.2e+02% | |
| copyTree 7561/483 = 1.6e+03% | |
| paramTypesMatchAux 4032/483 = 8.3e+02% | |
| paramTypesMatch 4032/483 = 8.3e+02% | |
| matchesAux 9109/483 = 1.9e+03% | |
| matches 10181/483 = 2.1e+03% | |
| pickBestCandidate 11237/483 = 2.3e+03% | |
| resolveOverloads 11061/483 = 2.3e+03% |
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
| import posix, os | |
| var pid = fork() | |
| if pid == 0: | |
| sleep(3000) | |
| quit(3) | |
| else: | |
| var status: cint = 1 | |
| var ret = waitpid(pid, status, 0) | |
| echo status |
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
| var test = cstring("foobar") | |
| test[0] = 'g' |
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
| proc toString(s: set[char]): string = | |
| result = "" | |
| for c in s: | |
| result.add c | |
| echo toString({'a'..'c'}) |
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
| var i = 20 | |
| while true: | |
| if i mod 19 == 0 and i mod 18 == 0 and i mod 17 == 0 and i mod 16 == 0 and | |
| i mod 15 == 0 and i mod 14 == 0 and i mod 13 == 0 and i mod 12 == 0 and | |
| i mod 11 == 0: | |
| echo "result: ", i | |
| break | |
| i += 20 |
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
| import algorithm | |
| proc nextPermutation[T](x: var openarray[T]): bool {.discardable.} = | |
| if x.len < 2: | |
| return false | |
| var i = x.high | |
| while i > 0 and x[i-1] >= x[i]: | |
| dec 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
| import os | |
| type CtrlCException = object of Exception | |
| proc handler() {.noconv.} = | |
| raise new CtrlCException | |
| setControlCHook(handler) | |
| try: |