File tree 7 files changed +79
-1
lines changed
7 files changed +79
-1
lines changed Original file line number Diff line number Diff line change
1
+ (define (apropos str (do -print true))
2
+ " Return symbols that matches the regexp."
3
+ (let ((acc (find-all str (symbols) $it
4
+ (lambda (x y)
5
+ (regex x (term y))))))
6
+ (when (and acc do -print)
7
+ (dolist (item acc)
8
+ (cond
9
+ ((primitive? (eval item))
10
+ (println item " \t " " <primitive>" ))
11
+ ((lambda ? (eval item))
12
+ (println item " \t " " <lambda>" ))
13
+ ((macro? (eval item))
14
+ (println item " \t " " <macro>" ))
15
+ (" else"
16
+ (println item)))))
17
+ acc))
Original file line number Diff line number Diff line change
1
+ ; ;; math.lsp
2
+
3
+ ; (import "msvcrt" "log10")
4
+ (define (log10 n) (log n 10 ))
Original file line number Diff line number Diff line change 36
36
PRECOMPILED 0x10000
37
37
)
38
38
39
+ ; ; 正規表現のオプション(//six)を数値に変換するヘルパー関数
40
+ ; ; v.10.6.2 より直接指定が利用可能
41
+ (define (re kwd)
42
+ (letn ((opt 0 )
43
+ (|| (lambda (i) (setq opt (| opt i)))))
44
+ (dostring (c kwd)
45
+ (case (char c)
46
+ (" i" (|| 1 )) ; PCRE_CASELESS
47
+ (" m" (|| 2 )) ; PCRE_MULTILINE
48
+ (" s" (|| 4 )) ; PCRE_DOTALL
49
+ (" x" (|| 8 )) ; PCRE_EXTENDED
50
+ (true (throw-error " unknown keyword" ))))
51
+ opt))
52
+
53
+
39
54
(context MAIN)
40
55
; ;; EOF
Original file line number Diff line number Diff line change
1
+ ; ;; sequence.lsp
2
+
3
+ (define (sample seq)
4
+ (unless (or (list ? seq)
5
+ (string? seq))
6
+ (throw-error " Error:LIST_OR_STRING_EXPECTED" ))
7
+ ; ;(first (randomize seq true))
8
+ (seq (rand (length seq))))
9
+
10
+ ; ; syntax: (range [from] to [step])
11
+ (define (range)
12
+ (case (length (args))
13
+ (1 (sequence 0 (args 0 )))
14
+ (2 (sequence (args 0 ) (args 1 )))
15
+ (3 (sequence (args 0 ) (args 1 ) (args 2 )))
16
+ (true '())))
Original file line number Diff line number Diff line change
1
+ ; ;; system.lsp
2
+
3
+ (define (has x)
4
+ (let ((features '((" library" 0x040 )
5
+ (" utf8" 0x080 )
6
+ (" newlisp64" 0x100 )
7
+ (" ipv6" 0x200 )
8
+ (" ffi" 0x400 ))))
9
+ (!= 0 (& (or (lookup (lower-case x) features) 0 )
10
+ (sys-info -1 )))))
11
+
12
+ (define (die)
13
+ (if (args) (write 2 (apply format (args))))
14
+ (exit))
15
+
16
+ (define (%bits i (len 64 ))
17
+ (replace " " (format (string " %" len " s" ) (bits i)) " 0" ))
Original file line number Diff line number Diff line change 1
- ; ; unicode.lsp
1
+ ; ;; unicode.lsp
2
2
3
3
(define (utf8?)
4
4
" Non-nil means newLISP is UTF-8 eoncoding are supported."
Original file line number Diff line number Diff line change
1
+ ; ;; utils.lsp
2
+
3
+ (define (compose)
4
+ " Compose function right-associatively."
5
+ (letex ((_fns (reverse (args))))
6
+ (lambda (x)
7
+ (dolist (f '_fns)
8
+ (setf x (f x)))
9
+ x)))
You can’t perform that action at this time.
0 commit comments