This file contains 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 fib(n: int): int = | |
if n <= 0: 1 | |
else: fib(n-1) + fib(n-2) | |
static: | |
echo fib(3) |
This file contains 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 tables, sequtils | |
let t = {1: "one", 2: "two"}.toTable | |
let k = toSeq(t.keys()) | |
echo k |
This file contains 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 sequtils | |
proc `[]`[T](s: openarray[T], x: int, y: Slice[int]): seq[T] = | |
result = newSeq[T]() | |
for i in countup(x, y.b, y.a - x): | |
result.add(s[i]) | |
let x = toSeq(0..20) | |
echo x[3,5..13] |
This file contains 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 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 times | |
proc fib(n: int32): int32 = | |
if n <= 1: n | |
else: fib(n-1) + fib(n-2) | |
proc main = | |
let timeStart = epochTime() | |
var result: int32 = 0 |
This file contains 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, times, future, math, sequtils, strutils | |
proc get_primes7(n: int32): seq[int32] = | |
if n < 2: | |
return @[] | |
result = @[2'i32] | |
if n == 2: | |
return |
This file contains 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 threadpool | |
# Array needs explicit size to work, probably related to issue #2287 | |
const a: array[0..5, int] = [1,2,3,4,5,6] | |
proc f(n) = echo "Hello ", n | |
proc main = | |
parallel: | |
for i in countup(0, a.high-1, 2): |
This file contains 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 base64, strutils, sha256, os | |
import libsodium.sodium | |
import libsodium.sodium_sizes | |
const | |
usage = """ | |
DDCATool - Tool to establish and manage a DDNet CA | |
usage: | |
ddcatool <command> | |
Commands: |
This file contains 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
template inReverse(x, y) = | |
y | |
x | |
inReverse do: | |
echo "Hello World" | |
do: | |
echo "Goodbye World" |
This file contains 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 asyncdispatch | |
template doAsync(name: expr; body: untyped): untyped {.immediate.} = | |
proc name() {.async.} = | |
body | |
asyncCheck(name()) | |
doAsync(namething): | |
echo "hello" |