-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
a85b46e
commit bb70f95
Showing
7 changed files
with
84 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
( | ||
(defmacro assert items | ||
(if (r items) | ||
(list if (f items) (c assert (r items)) (q . (x))) | ||
(f items) | ||
(defun assert_ (items) | ||
(if (r items) | ||
(qq (if (unquote (f items)) (unquote (assert_ (r items))) (x))) | ||
(f items) | ||
) | ||
) | ||
) | ||
|
||
(defmac assert items (assert_ items)) | ||
) |
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 |
---|---|---|
@@ -1,39 +1,44 @@ | ||
( | ||
(defun last_inner ((next . remainder)) | ||
(if remainder | ||
(last_inner remainder) | ||
next | ||
) | ||
(defun prefix (L P) | ||
(if L | ||
(c (f L) (prefix (r L) P)) | ||
P | ||
) | ||
) | ||
|
||
(defmacro last ARGS | ||
(defun snoc (L agg) | ||
(if L | ||
(if (r L) | ||
(snoc (r L) (c (f L) agg)) | ||
(c (f L) agg) | ||
) | ||
(c () ()) | ||
) | ||
) | ||
(defun last_inner ((next . remainder)) | ||
(if remainder | ||
(last_inner remainder) | ||
next | ||
) | ||
) | ||
|
||
(defun snoc (L agg) | ||
(if L | ||
(if (r L) | ||
(snoc (r L) (c (f L) agg)) | ||
(c (f L) agg) | ||
) | ||
(c () ()) | ||
) | ||
) | ||
|
||
(defun echo myargs | ||
myargs | ||
) | ||
|
||
(defun prefix (L P) | ||
(if L | ||
(c (f L) (prefix (r L) P)) | ||
P | ||
) | ||
) | ||
(defmac last ARGS | ||
|
||
(if ARGS | ||
(if (r ARGS) | ||
(assign | ||
(final . rest) (snoc ARGS ()) | ||
reversed (prefix rest (list final)) | ||
(qq (last_inner (unquote (c list reversed)))) | ||
) | ||
(qq (last_inner (unquote (f ARGS)))) | ||
) | ||
(x "Last takes at least one argument") | ||
(if ARGS | ||
(if (r ARGS) | ||
(assign | ||
(final . rest) (snoc ARGS ()) | ||
reversed (prefix rest (echo final)) | ||
(qq (last_inner (unquote (c (q . echo) reversed)))) | ||
) | ||
(qq (last_inner (unquote (f ARGS)))) | ||
) | ||
(x "Last takes at least one argument") | ||
) | ||
) | ||
) |
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,37 @@ | ||
|
||
(mod () | ||
(include *standard-cl-23*) | ||
(include print.clinc) | ||
(include assert.clinc) | ||
(include deep_compare.clinc) | ||
(include reverse.clinc) | ||
(include prepend.clinc) | ||
(include map.clinc) | ||
(include range.clinc) | ||
(include permutations.clinc) | ||
(include last.clinc) | ||
(include busy.clinc) | ||
(include onehandcalc.clinc) | ||
|
||
(defun try_list (mylist newlist) | ||
(assert (deep= (print 'result' (atomsort (print 'about to sort' newlist))) mylist) 0) | ||
) | ||
|
||
(defun try_permuted_list (mylist) | ||
(busy (lambda ((& mylist) newlist) (try_list mylist newlist)) | ||
(permutations mylist) | ||
0 | ||
) | ||
) | ||
(last | ||
(try_list 0 0) | ||
(try_list (range 15) (range 15)) | ||
(try_list (range 15) (reverse (range 15))) | ||
(try_permuted_list (list -1 -1 0 0 2)) | ||
(busy (lambda (i) (try_permuted_list (range i))) | ||
(range 4) | ||
0 | ||
) | ||
1 | ||
) | ||
) |