Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(define (apropos str (do-print true)) | ||
"Return symbols that matches the regexp." | ||
(let ((acc (find-all str (symbols) $it | ||
(lambda (x y) | ||
(regex x (term y)))))) | ||
(when (and acc do-print) | ||
(dolist (item acc) | ||
(cond | ||
((primitive? (eval item)) | ||
(println item "\t" "<primitive>")) | ||
((lambda? (eval item)) | ||
(println item "\t" "<lambda>")) | ||
((macro? (eval item)) | ||
(println item "\t" "<macro>")) | ||
("else" | ||
(println item))))) | ||
acc)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
;;; math.lsp | ||
|
||
;(import "msvcrt" "log10") | ||
(define (log10 n) (log n 10)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
;;; sequence.lsp | ||
|
||
(define (sample seq) | ||
(unless (or (list? seq) | ||
(string? seq)) | ||
(throw-error "Error:LIST_OR_STRING_EXPECTED")) | ||
;;(first (randomize seq true)) | ||
(seq (rand (length seq)))) | ||
|
||
;; syntax: (range [from] to [step]) | ||
(define (range) | ||
(case (length (args)) | ||
(1 (sequence 0 (args 0))) | ||
(2 (sequence (args 0) (args 1))) | ||
(3 (sequence (args 0) (args 1) (args 2))) | ||
(true '()))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
;;; system.lsp | ||
|
||
(define (has x) | ||
(let ((features '(("library" 0x040) | ||
("utf8" 0x080) | ||
("newlisp64" 0x100) | ||
("ipv6" 0x200) | ||
("ffi" 0x400)))) | ||
(!= 0 (& (or (lookup (lower-case x) features) 0) | ||
(sys-info -1))))) | ||
|
||
(define (die) | ||
(if (args) (write 2 (apply format (args)))) | ||
(exit)) | ||
|
||
(define (%bits i (len 64)) | ||
(replace " " (format (string "%" len "s") (bits i)) "0")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
;; unicode.lsp | ||
;;; unicode.lsp | ||
|
||
(define (utf8?) | ||
"Non-nil means newLISP is UTF-8 eoncoding are supported." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
;;; utils.lsp | ||
|
||
(define (compose) | ||
"Compose function right-associatively." | ||
(letex ((_fns (reverse (args)))) | ||
(lambda (x) | ||
(dolist (f '_fns) | ||
(setf x (f x))) | ||
x))) |