add at and hibye examples

This commit is contained in:
darkf 2013-10-23 15:39:01 -07:00
parent b1fc1a3715
commit 5c341d7df4
2 changed files with 22 additions and 0 deletions

15
examples/at.lamb Normal file
View File

@ -0,0 +1,15 @@
-- at (indexer) function, for lists and strings
-- out of values (hey, this isn't the Circus of Values!)
at([], _) -> -1.
at("", _) -> -1.
-- we've hit our target item
at(x::_, 0) -> x.
-- we've got more to go, keep iterating
at(x::xs, i) -> at(xs, i-1).
-- test
print(at([1, 2, 3, 4], 2)).
print(at("hi there", 1)).

7
examples/hibye.lamb Normal file
View File

@ -0,0 +1,7 @@
-- demonstrates string patterns
f("hi") -> "hello to you too!".
f("bye") -> "goodbye!".
putstrln(f("hi")).
putstrln(f("bye")).