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 | |
TPerson = object # I prepended a T because that is the Nimrod convention. It also gets rid of possible clashes, like in `$` :) | |
name*: string | |
age*: int | |
proc newPerson(name: string, age: int): TPerson = | |
result.name = name | |
result.age = age | |
proc `<=>`(person1: TPerson, person2: TPerson): bool = |
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 jester, strtabs | |
get "/": | |
@"<h1>Hello world</h1>" | |
get "/awesome": | |
@"<h1>Awesomness :D</h1>" | |
run() |
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 algorithm, strutils | |
proc cmpPlatforms(a, b: string): int = | |
if a == b: return 0 | |
var dashes = a.split('-') | |
var dashes2 = b.split('-') | |
if dashes[0] == dashes2[0]: | |
if dashes[1] == dashes2[1]: return system.cmp(a,b) | |
case dashes[1] | |
of "x86": |
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 addOne(n: var int) = | |
n += 1 | |
var number = 0 | |
number.addOne() |
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
var L = d.delegates.len | |
var dc = 0 | |
while dc < L: | |
template deleg: expr = d.delegates[dc] | |
let aSock = deleg.getSocket(deleg.deleVal) | |
if (deleg.mode != MWriteable and aSock.info == SockConnected) or | |
aSock.info == SockListening: | |
readSocks.add(aSock.sock) | |
if aSock.info == SockConnecting or | |
(aSock.info == SockConnected and deleg.mode != MReadable): |
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
{ "black": [ | |
"_? There's an app for that", | |
"Why can't I sleep at night? _", | |
"What's that smell? _", | |
"I got 99 problems but _ ain't one.", | |
"Who stole the cookies from the cookie jar? _", | |
"What's the next Happy Meal (r) toy? _", | |
"Anthropologists have recently discovered a primitive tribe that worships _.", | |
"It's a pity that kids these days are all getting involved with _.", | |
"During Picasso's often-overlooked Brown Period, he produced hundreds of paintings of _.", |
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
# Compile with --threads:on | |
import math, os, strutils, osproc, locks | |
type | |
TComplex = tuple[re, im: float] | |
TThrParam = tuple[start, size, realsize, id: int] | |
var bytes: array[0..3, cstring] | |
var lengths: array[0..3, int] |
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
> /home/dominik/code/outside/git/Nimrod/bin/nimrod c /home/dominik/code/nimrod/bugs/styleinsensitivity/test.nim | |
Hint: used config file '/home/dominik/code/outside/git/Nimrod/config/nimrod.cfg' [Conf] | |
Hint: system [Processing] | |
Hint: test [Processing] | |
test.nim(2, 5) Error: invalid token: _ | |
> Process terminated with exit code 1 |
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 | |
MyType = object | |
field: string, | |
exportedField*: int64 | |
proc foo(arg: var MyType) = | |
arg.field = "bar" | |
when isMainModule(): | |
echo("Hello") |
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
#include <windows.h> | |
#include <tchar.h> | |
#include <stdio.h> | |
#define BUF_SIZE (61) | |
LPCTSTR ErrorMessage( DWORD error ) | |
// Routine Description: | |
// Retrieve the system error message for the last-error code |