Skip to content

MonliH/zircon

Repository files navigation

zircon 💎

a purely functional language[*]


hello world:

print "Hello, World!"

fibonacci sequence:

let fib_seq = 0 : 1 : (zip_with (+) fib_seq (tail fib_seq))

print $ index fib_seq 11
# 89

factorial:

let (!)@ = \n -> if (n == 0) 1 (n * ((n-1)!))
postop (!) 10

print 12!
# 479001600

design:

  • no mutable variables
  • is interpreted via lazy evaluation, à la Haskell
  • made with haskell in mind, but it's extremely minimal syntax made it turn out more like lisp or smalltalk

build & usage

Install the dotnet build tools. Then:

git clone https://github.com/MonliH/zircon-lang.git
cd zircon-lang
dotnet build -c Release

To start the REPL:

$ ./ZirconLang/bin/Release/net5.0/ZirconLang
zλ> 

To run a file:

$ ./ZirconLang/bin/Release/net5.0/ZirconLang Examples/fib.zn
832040

You can also add net5.0/ to your PATH for convenience.

more examples

mandelbrot set:

$ ./ZirconLang/bin/Release/net5.0/ZirconLang ./Examples/mandelbrot.zn
###############################################++++++++.. .  +++++#############
#############################################++++++++++..   ..+++++############
############################################++++++++++...   ..++++++###########
###########################################++++++++++.       .+++++++##########
##########################################+++++++++....      ..++++++##########
#########################################++++++++......      ....+++++#########
#######################################++++++++.......        ..... +++########
######################################++++++++..                ... .++########
#####################################++++++++...                     ++########
####################################++++++++....                    .+++#######
##################################+++++++++....                     ..++#######
################################+++...+++.....                      ..+++######
#############################+++++. ..........                      . +++######
##########################+++++++.. ...  ....                         +++######
########################+++++++++..        ..                        ..++######
#######################++++++++++...                                 .++++#####
######################++++++++++...                                  .++++#####
#####################+++++++++.. .                                   .++++#####
#####################+++++......                                    ..++++#####
#####################++........                                     ..++++#####
#####################                                              ...++++#####
#####################++........                                     ..++++#####
#####################+++++......                                    ..++++#####
#####################+++++++++.. .                                   .++++#####
######################++++++++++...                                  .++++#####
#######################++++++++++...                                 .++++#####
########################+++++++++..        ..                        ..++######
##########################+++++++.. ...  ....                         +++######
#############################+++++. ..........                      . +++######
################################+++...+++.....                      ..+++######
##################################+++++++++....                     ..++#######
####################################++++++++....                    .+++#######
#####################################++++++++...                     ++########
######################################++++++++..                ... .++########
#######################################++++++++.......        ..... +++########
#########################################++++++++......      ....+++++#########
##########################################+++++++++....      ..++++++##########
###########################################++++++++++.       .+++++++##########
############################################++++++++++...   ..++++++###########
#############################################++++++++++..   ..+++++############

For more, see the examples folder.

it's technically not purely functional

Ok, that's true. Because I didn't want to implement something like the IO monad and friends, print statements are run imperatively.

About

an interpreted and purely functional toy language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages