Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latte

A small Lisp written in Go, with an embeddable API and a CLI with a REPL.

Lisp

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

Go

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

CLI

Install:

go install github.com/igorcafe/latte/cmd/latte@latest

Use as a REPL:

latte

Run files:

latte example.lisp

About

Latte 🐶: A Lisp-like interpreter written in Go

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages