A small Lisp written in Go, with an embeddable API and a CLI with a REPL.
(define tax-rate 0.1)
(define (line-total price quantity)
(* price quantity))
(define (checkout subtotal discount)
(let ((tax (* subtotal tax-rate)))
(- (+ subtotal tax) discount)))
(println "total:" (checkout (line-total 25 3) 10))package main
import (
"fmt"
"log"
"github.com/igorcafe/latte"
)
func main() {
env := latte.NewEnv()
env.Define("name", "Latte")
env.RegisterFunction("shout", func(args []any) any {
return fmt.Sprintf("%s!", args[0])
})
value, err := env.Eval(`(shout name)`)
if err != nil {
log.Fatal(err)
}
fmt.Println(value)
}Install:
go install github.com/igorcafe/latte/cmd/latte@latestUse as a REPL:
latteRun files:
latte example.lisp