diff --git a/examples/at.lamb b/examples/at.lamb new file mode 100644 index 0000000..e125610 --- /dev/null +++ b/examples/at.lamb @@ -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)). \ No newline at end of file diff --git a/examples/hibye.lamb b/examples/hibye.lamb new file mode 100644 index 0000000..3b8d577 --- /dev/null +++ b/examples/hibye.lamb @@ -0,0 +1,7 @@ +-- demonstrates string patterns + +f("hi") -> "hello to you too!". +f("bye") -> "goodbye!". + +putstrln(f("hi")). +putstrln(f("bye")). \ No newline at end of file