Sloe is simple purely functional language based on lambda-calculus. It uses Lambda as dependency for evaluation of lambda-expressions.
For full source code see tree.sloe
Source code:
...
result = tree-to-list (create-tree (pair 3 (pair 0 (pair 2 (pair 4 (pair 1 nil))))))
select 0 result
select 1 result
select 2 result
select 3 result
select 4 result
Output:
$ time cabal run sloe examples/tree.sloe
Up to date
\f.\x.x
\f.\x.(f x)
\f.\x.(f (f x))
\f.\x.(f (f (f x)))
\f.\x.(f (f (f (f x))))
For full source code see recursion.sloe
Source code:
...
fact' r n = if (iszero n) 1 (mul n (r r (pred n)))
fact n = fact' fact' n
fact 4
Output:
$ cabal run sloe examples/recursion.sloe
Up to date
\f.\x.(f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f x))))))))))))))))))))))))
For full source code see primes.sloe
Source code:
...
p = primes list
select 0 p
select 1 p
select 2 p
select 3 p
Output:
$ cabal run sloe examples/primes.sloe
Up to date
\f.\x.(f (f x))
\f.\x.(f (f (f x)))
\f.\x.(f (f (f (f (f x)))))
\f.\x.(f (f (f (f (f (f (f x)))))))
For full source code see fizzbuzz.sloe
Source code:
...
fizzbuzz n = if (and (iszero (mod n 3)) (iszero (mod n 5))) FizzBuzz (if (iszero (mod n 3)) Fizz (if (iszero (mod n 5)) Buzz n))
result = rangef fizzbuzz 0 20
select 1 result
select 2 result
select 3 result
select 4 result
select 5 result
select 6 result
...
Output:
$ cabal run sloe examples/fizzbuzz.sloe
Up to date
\f.\x.(f x)
\f.\x.(f (f x))
Fizz
\f.\x.(f (f (f (f x))))
Buzz
Fizz
\f.\x.(f (f (f (f (f (f (f x)))))))
\f.\x.(f (f (f (f (f (f (f (f x))))))))
Fizz
Buzz
\f.\x.(f (f (f (f (f (f (f (f (f (f (f x)))))))))))
Fizz
\f.\x.(f (f (f (f (f (f (f (f (f (f (f (f (f x)))))))))))))
\f.\x.(f (f (f (f (f (f (f (f (f (f (f (f (f (f x))))))))))))))
FizzBuzz
\f.\x.(f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f x))))))))))))))))
\f.\x.(f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f x)))))))))))))))))
Fizz