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
# Hello world program | |
type | |
Implies[A, B] = proc(a: A): B | |
# example Propositions | |
type | |
X = object | |
Y = object | |
Z = object |
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
type | |
V[T; I: static[int]] = array[0..I, T] | |
proc foo(x: V): V.T = | |
result = x[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
const htmlElements = ["a", "div", "head"] | |
for e in htmlElements: | |
template (e) (body) = | |
echo "<" & e & ">" | |
body | |
echo "</" & e & ">" | |
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
int MakeGetRequest(const TCHAR* server, const TCHAR* url, string& out) | |
{ | |
auto inet = InternetOpen(_T("AdRotate"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, 0, 0); | |
if(inet == NULL) | |
return 1; | |
auto session = InternetConnect(inet, server, 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, NULL); | |
if(session == NULL) | |
return 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
type | |
Matrix[Rows, Cols: static[int]; E] = generic M | |
M.T is T | |
Rows == M.M | |
Cols == M.N | |
m[range[0..(R - 1)], range[0..(C - 1)]] is T | |
proc foo(m: Matrix) = | |
echo Matrix.M, m.N | |
let x = Matrix.E() |
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
type | |
DenseMatrixLayout* {.pure.} = enum | |
ColumnMajor, | |
RowMajor | |
DenseMatrix*[R, C: static[int], T; L: static[DenseMatrixLayout]] = object | |
elements: array[R*C, T] | |
Matrix4 = DenseMatrix[4, 4, float, DenseMatrixLayout.ColumnMajor] |
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
#define HTTP_STATUS_CODES(_) \ | |
_(200, OK) \ | |
_(404, NOT_FOUND) \ | |
_(505, INTERNAL_ERROR) | |
enum StatusCodes { | |
#define GENERATE_ENUM(CODE, MSG) MSG = CODE, | |
HTTP_STATUS_CODES(GENERATE_ENUM) | |
} |
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
--langdef=nimrod | |
--langmap=nimrod:.nim | |
--regex-nimrod=/(\w+)\*?\s*=\s*object/\1/c,Class/ | |
--regex-nimrod=/proc\s+(\w+)/\1/m,Procedure/ | |
--regex-nimrod=/proc\s+`([^`]+)`/\1/o,Operator/ |
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 testConcat(a: string, b: string): string {.compileTime pure.} = | |
return a & b | |
const X = testConcat("test", "me") | |
proc test = | |
when len(X) > 2: | |
echo "big" | |
else: | |
echo "small" |
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
type 3DSpace = ... | |
type Plane = ... | |
type Line = ... | |
proc SpaceSplitterType(p: Place) : Line | |
proc SpaceSplitterType(p: 3DSpace) : Plane | |
# This is a generic algorithm that should work both in 2D and 3D context | |
proc ComputeProjection[S](space: S) = | |
# instantiate the correct space splitter type (needed for the algorithm) |
OlderNewer