High-level, functional, interpreted, dynamic programming language: Crumb

Crumb is the latest open source programming language, and after its release, it aroused widespread discussion in the programming section of Reddit .

As the title says, Crumb is a functional programming language, and there are no "keywords", everything is a function (0 keywords, everything is a function.). Other features include providing garbage collection (GC), dynamic typing, having a concise syntax, and a detailed standard library.

sample code

table = (map (range 10) {_ y ->
  <- (map (range 10) {item x ->
    <- (multiply (add x 1) (add y 1))
  })
})
(loop 100 {i -> 
  i = (add i 1)
  
  (if (is (remainder i 15) 0) {
    (print "fizzbuzz\n")
  } {
    (if (is (remainder i 3) 0) {
      (print "fizz\n")
    } {
      (if (is (remainder i 5) 0) {
        (print "buzz\n")
      } {
        (print i "\n")
      })
    })
  })
})
  • Implementing the Fibonacci sequence
// use a simple recursive function to calculate the nth fibonacci number
fibonacci = {n ->
  <- (if (is n 0) {<- 0} {
    <- (if (is n 1) {<- 1} {
      <- (add 
        (fibonacci (subtract n 1)) 
        (fibonacci (subtract n 2))
      )
    })
  })
}

(until "stop" {state n ->
  (print (add n 1) "-" (fibonacci (add n 1)) "\n")
})

More sample code: https://github.com/liam-ilan/crumb/tree/main/examples

The standard library includes: IO, Comparisons, Logical Operators, Arithmetic, etc.

Guess you like

Origin www.oschina.net/news/255875/crumb-language