-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace mapcar by apply * Add map and reduce to core lib * Add pi.lsp example * Fix tests * Refactor pi-digits * Move builtin join to core lib as string-join * Rename decode-* and encode-* to *-decode and *-encode * Update doc
- Loading branch information
Showing
5 changed files
with
64 additions
and
46 deletions.
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
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 @@ | ||
(load "/lib/lisp/core.lsp") | ||
|
||
(defn pi-nth (n) | ||
(* (^ 16 (- n)) (- | ||
(/ 4 (+ 1 (* 8 n))) | ||
(/ 2 (+ 4 (* 8 n))) | ||
(/ 1 (+ 5 (* 8 n))) | ||
(/ 1 (+ 6 (* 8 n)))))) | ||
|
||
(defn pi-digits (n) | ||
(apply + (map pi-nth (range 0 n)))) | ||
|
||
(println | ||
(cond | ||
((null? args) "Usage: pi <precision>") | ||
(true (pi-digits (parse (car args)))))) |
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