8000 GitHub - DanielTheKrote/liwb: A lisp like interpreted language written in rust
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

DanielTheKrote/liwb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Liwb

Like lisp, but with w and b

Static Badge Static Badge

What's the projects about 📖

Liwb is a simple (and stupid) lisp like interpreted programming language. It does not have a real purpose, i just made it for fun. Perhaps, it is capable of doing some interesting stuff.

Examples

First 13 Fibbonacci sequence

(fn fib [n]
    (if (<= n 2)
        (if (= n 1) 
            0
            1)
        (+ (fib (- n 1)) (fib (- n 2)))))

(print (map fib (range 1 13)))

output:

    [ 0 1 1 2 3 5 8 13 21 34 55 89 144  ]

Fizzbuz

(fn fizz-buzz [number]
    (if (= 0 (mod number 3))
        (if (= 0 (mod number 5))
                "FizzBuzz"
                "Fizz")
        (if (= 0 (mod number 5))
            "Buzz"
            number)))

(define numbers (range 1 20))
(print (map fizz-buzz numbers))

output:

    [ 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz  ]

FibFizzBuzz

(fn fib [n]
    (if (<= n 2)
        (if (= n 1) 
            0
            1)
        (+ (fib (- n 1)) (fib (- n 2)))))

(fn fizzbuzz [n]
    (if (= (mod n 15) 0)
        "FizzBuzz"
        (if (= (mod n 3) 0)
            "Fizz"
            (if (= (mod n 5) 0)
                "Buzz"
                n))))

(define fibonacci-sequence (map fib (range 1 20)))
(define fizzbuzz-fibonacci (map fizzbuzz fibonacci-sequence))
(print fizzbuzz-fibonacci)

output:

[ "FizzBuzz" 1 1 2 "Fizz" "Buzz" 8 13 "Fizz" 34 "Buzz" 89 "Fizz" 233 377 "Buzz" "Fizz" 1597 2584 4181]

How to use the language and how it works 📜

See Docs

License ⚖️

The Program is under the MIT license

About

A lisp like interpreted language written in rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0