You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With `prime?` provided, filter twin prime numbers in this way:
33
-
```scheme
34
-
(import (liii lang))
35
-
36
-
(($ 1 :to 100)
37
-
:filter prime?
38
-
:filter (lambda (x) (prime? (+ x 2)))
39
-
:map (lambda (x) (cons x (+ x 2)))
40
-
:collect)
41
-
```
42
-
43
-
### Scala like case class
44
-
```scheme
45
-
(define-case-class person
46
-
((name string?)
47
-
(age integer?))
48
-
49
-
(define (%to-string)
50
-
(string-append "I am " name " " (number->string age) " years old!"))
51
-
(define (%greet x)
52
-
(string-append "Hi " x ", " (%to-string))))
53
-
54
-
(define bob (person "Bob" 21))
55
-
56
-
(bob :to-string) ; => "I am Bob 21 years old!"
57
-
(bob :greet "Alice") ; => "Hi Alice, I am Bob 21 years old!"
58
-
```
59
-
60
-
> **Performance Warning**: `define-case-class` is implemented via macros and has significant performance overhead. It is suitable for hand-written code and prototyping, but **not recommended for AI-generated code or production deployments**.
61
-
62
12
## Simplicity is Beauty
63
13
Goldfish Scheme still follows the same principle of simplicity as S7 Scheme. Currently, Goldfish Scheme only depends on [S7 Scheme](https://ccrma.stanford.edu/software/s7/), [tbox](https://gitee.com/tboox/tbox) and C++ standard library defined in C++ 98.
64
14
65
15
Just like S7 Scheme, [src/goldfish.hpp](src/goldfish.hpp) and [src/goldfish.cpp](src/goldfish.cpp) are the only key source code needed to build the goldfish interpreter binary.
66
16
67
17
68
18
## Standard Library
69
-
### Scala-like collections
70
-
| Library | Description |
71
-
|---------|-------------|
72
-
|[(liii rich-char)](tests/goldfish/liii/rich-char-test.scm)| boxed char with rich char and instance methods |
73
-
|[(liii rich-string)](tests/goldfish/liii/rich-string-test.scm)| boxed string with rich char and instance methods |
74
-
|[(liii rich-list)](tests/goldfish/liii/rich-list-test.scm)| boxed list with rich static and instance methods |
75
-
|[(liii rich-vector)](tests/goldfish/liii/rich-vector-test.scm)| boxed vector with rich static and instance methods |
76
-
|[(liii rich-hash-table)](tests/goldfish/liii/rich-hash-table-test.scm)| boxed hash-table with rich static and instance methods |
77
-
|[(liii rich-path)](tests/goldfish/liii/rich-path-test.scm)| boxed path with rich static and instance methods |
78
-
79
19
### Python-like standard library
80
20
81
21
| Library | Description | Example functions |
@@ -94,7 +34,10 @@ Just like S7 Scheme, [src/goldfish.hpp](src/goldfish.hpp) and [src/goldfish.cpp]
On startup, Goldfish also automatically prepends each directory under `~/.local/goldfish/` whose name matches `xxx-yyy` and which contains at least one `.scm` file.
0 commit comments