Coder Social home page Coder Social logo

sloe's Introduction

Haskell CI

Sloe: Purely functional language

Sloe is simple purely functional language based on lambda-calculus. It uses Lambda as dependency for evaluation of lambda-expressions.

Examples

Binary Search Tree

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))))

Factorial

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))))))))))))))))))))))))

Primes

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)))))))

FizzBuzz

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

sloe's People

Contributors

drearylisper avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.