diff options
| author | E7-87-83 <fungcheokyin@gmail.com> | 2020-09-21 07:19:23 +0800 |
|---|---|---|
| committer | E7-87-83 <fungcheokyin@gmail.com> | 2020-09-21 07:19:23 +0800 |
| commit | a17eef230d6dca0a32a725ddadfb3e963093be28 (patch) | |
| tree | d968791776e156eafc3e98037e7538fe8dfa49ee | |
| parent | 57cdc88f2c0481d83653ff79a53733ce3174d805 (diff) | |
| download | perlweeklychallenge-club-a17eef230d6dca0a32a725ddadfb3e963093be28.tar.gz perlweeklychallenge-club-a17eef230d6dca0a32a725ddadfb3e963093be28.tar.bz2 perlweeklychallenge-club-a17eef230d6dca0a32a725ddadfb3e963093be28.zip | |
lisp scripts
| -rw-r--r-- | challenge-078/cheok-yin-fung/common-lisp/ch-1.lsp | 18 | ||||
| -rw-r--r-- | challenge-078/cheok-yin-fung/common-lisp/ch-2.lsp | 27 |
2 files changed, 45 insertions, 0 deletions
diff --git a/challenge-078/cheok-yin-fung/common-lisp/ch-1.lsp b/challenge-078/cheok-yin-fung/common-lisp/ch-1.lsp new file mode 100644 index 0000000000..792cb452bd --- /dev/null +++ b/challenge-078/cheok-yin-fung/common-lisp/ch-1.lsp @@ -0,0 +1,18 @@ +; The Weekly Challenge - Perl & Raku #078 Task 1 +; Common Lisp script + +(setf mylist (list 9 10 7 5 6 1)) + +(setf *max* -10000) + +(setf ans nil) + +(setf rmylist (reverse mylist)) + +(dolist (x rmylist) (progn + (setf s (pop rmylist)) + (if (> s *max*) (progn + (setf *max* s) + (push s ans))))) + +(print ans) diff --git a/challenge-078/cheok-yin-fung/common-lisp/ch-2.lsp b/challenge-078/cheok-yin-fung/common-lisp/ch-2.lsp new file mode 100644 index 0000000000..e68ee02b81 --- /dev/null +++ b/challenge-078/cheok-yin-fung/common-lisp/ch-2.lsp @@ -0,0 +1,27 @@ +; The Weekly Challenge - Perl & Raku #078 Task 2 +; Common Lisp Script +; ref: https://stackoverflow.com/questions/16678371/circular-list-in-common-lisp +; answered by Rainer Joswig + +(setf *print-circle* t) ; or the Lisp interpreter will crash IF + ; it is required to handle the circular list + +(setf mylist (list 10 20 30 40 50)) +(setf list-len (length mylist)) +(setf rotated-indices (list 3 4)) + +(defun circular (items) + (setf (cdr (last items)) items) + items) + +(circular mylist) + +(defun main (num-list) + (dolist (x num-list) (progn + (setf temp-list nil) + (dotimes (i list-len) + (push (nth (+ i x) mylist) temp-list)) + (nreverse temp-list) + (print temp-list)))) + +(main rotated-indices) |
