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 | |
type | |
MKD_FLAG = cuint | |
PMMIOT = pointer | |
proc mkd_in(inputFile: TFile, | |
mflag: MKD_FLAG) : | |
PMMIOT {.importc: "mkd_in", | |
dynlib: "libmarkdown.so(.2|.2.1.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 macros | |
## TODO: Convert to a template/macro | |
#dumpTree: | |
# proc newSeq[T](s: Slice): seq[T] = | |
# var retvar = newSeq[T](len=(s.b-s.a)+1) | |
# for i in s.a..s.b: | |
# retvar[i-(s.a)] =i | |
# return retvar | |
# | |
# var input = newSeq[int](-8..8) |
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
[1] pry(SafeYAML::PsychResolver)> show-source -a Psych | |
Found 2 candidates for `Psych` definition: | |
Candidate 1/2: /home/singularperturbation/.rbenv/versions/2.2.0/lib/ruby/2.2.0/psych/syntax_error.rb @ line 3: | |
Number of lines: 19 | |
module Psych | |
class SyntaxError < Psych::Exception | |
attr_reader :file, :line, :column, :offset, :problem, :context |
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
iterator doStuff*(str: string, endpos = int.high): int = | |
# let strlen = if endpos == int.high: str.len else: endpos+1 | |
# yield strlen | |
if endpos == int.high: | |
yield str.len | |
else: | |
yield endpos+1 #ERROR - Will not compile | |
for num in doStuff("HEY"): | |
echo num |
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 | |
# Compiles if declared as global here: | |
# | |
# var toChange = false | |
proc main() = | |
var toChange = false |
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
## Example of using linalg library with ref-counting GC. If *just* have ptr DMatrix64, then | |
## it will get GC'd since the DMatrix64 is a ref to an object - the GC doesn't keep track of ptrs (duh) | |
## so this will be collected on the next cycle. | |
## | |
## Solution is as the example in the manual for the string in the 'Data' tuple. Ideal solution would be | |
## automatically-managed memory container with destructor that deallocates the matrix, but the Matrix | |
## definition might have to be managed to support that. | |
import linalg | |
import threadpool |
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 Foo = object | |
fooInt*: int | |
proc main() = | |
# Error: type mismatch: got (ptr Foo) but expected 'ptr None' | |
var f = create(Foo) | |
f.fooInt = 3 | |
echo $f | |
discard realloc(f, 0) |