Skip to content

Goldfish Scheme v17.11.2

Latest
Compare
Choose a tag to compare
@da-liii da-liii released this 12 Jan 14:05
> bin/goldfish --version
Goldfish Scheme 17.11.2 by LiiiLabs
based on S7 Scheme 11.2 (30-Dec-2024)

Goldfish Scheme v17.11.2 will be built-in in Mogan STEM Suite v1.2.9.9.

New Modules (liii lang)

The module improves the usability of Goldfish Scheme significantly

  • Functional Data Pipeline like Scala collection or Java Stream API
  • Unicode support by case-string and case-char

Demo Code for Unicode support

((box "你好,世界") 0) ; => 你
((box "你好,世界") 4) ; => 界
((box "你好,世界") :length) ; => 5

Demo code for functional data pipelines

((box (list 1 2 3 4 5))
 :map (lambda (x) (* x x))
 :filter even?
 :collect) ; => (list 4 16)

((box (vector 1 2 3 4 5))
 :map (lambda (x) (* x x))
 :filter even?
 :collect) ; => (vector 4 16)

Improved define-case-class

define-case-class is the Scala case class alternative in Goldfish Scheme. For Goldfish Scheme v17.11.2, the only missing feature for define-case-class is that generating hash-code method automatically.

(define-case-class person
  ((name string?)
   (age integer?))
  
  (define (%to-string)
    (string-append "I am " name " " (number->string age) " years old!"))
  (define (%greet x)
    (string-append "Hi " x ", " (%to-string))))

(define bob (person "Bob" 21))

(bob :to-string) ; => "I am Bob 21 years old!"
(bob :greet "Alice") ; => "Hi Alice, I am Bob 21 years old!"