Skip to content

Instantly share code, notes, and snippets.

@alexnask
Created June 26, 2011 07:13
Show Gist options
  • Select an option

  • Save alexnask/1047348 to your computer and use it in GitHub Desktop.

Select an option

Save alexnask/1047348 to your computer and use it in GitHub Desktop.
some stiff-lang snippets 8D
Foo: {
bar: fn printfln("Hello World!")
}
Foo.bar()
map: [
"foo":Foo
"bar":{ bar: fn printfln("Bye, World!") }
]
map.each (fn (key,value) {
printfln("%s says %s",key,value.bar())
})
hw: Foo.bar
hw() // Hello World!
Foo.bar: fn prntfln("Bye World!")
hw() // Should this print Hello World! or Bye World! ?
// I guess the question is when we do hw: Foo.bar, do we pass a reference or a value?
tuple:() // What is the type of tuple?
// I would say it should be "void"
// Should pattern matching be made this way now?
fib: fn (0) 0
fib: fn (1) 1
fib: fn (n) {
fib(n-1) + fib(n-2)
}
Baz: {
num: 0
foo: fn(f) {
if(num != 0) f(num)
else 0
}
}
executeAll: fn (nil,nil) nil
executeAll: fn (f,nil) f()
executeAll: fn (f,fs...) {
f()
executeAll fs // fs is a tuple, right? ;)
}
executeAll(
fn println("Hello World!"),
fn println("Bye World!")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment