Goldfish Scheme v17.11.2 已经发布,Scheme 解释器
Goldfish Scheme v17.11.2 已经发布,Scheme 解释器
此版本更新内容包括:
> bin/goldfish --version
Goldfish Scheme 17.11.2 by LiiiLabs
based on S7 Scheme 11.2 (30-Dec-2024)
Goldfish Scheme v17.11.2将会在墨干理工套件v1.2.9.9中内置。
新模块(liii lang)
这个模块大大提升了Goldfish Scheme易用性
- 提供了类似Scala标准库和Java 8 Stream API的函数式数据管道
- 在case-char和case-string中实现了Unicode支持
Unicode支持的示例代码:
((box "你好,世界") 0) ; => 你
((box "你好,世界") 4) ; => 界
((box "你好,世界") :length) ; => 5
函数式数据管道的示例代码
((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)
完善了define-case-class
define-case-class是Goldfish Scheme用于定义样本类的函数,本次更新完善了该函数,除了没有默认生成hashCode之外,define-case-class的功能已经能够覆盖Scala的case class的几乎所有使用场景。
示例代码
(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!"