diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-09-21 01:07:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-21 01:07:58 +0100 |
| commit | 4b2656edcbceca0f953707a1c2970f15a3727109 (patch) | |
| tree | c42d5d4d6cda6fed78ca58ac1b172435c74697d8 /challenge-078 | |
| parent | c495343d52dae9415a6ea527beaf33bbed923bad (diff) | |
| parent | a17eef230d6dca0a32a725ddadfb3e963093be28 (diff) | |
| download | perlweeklychallenge-club-4b2656edcbceca0f953707a1c2970f15a3727109.tar.gz perlweeklychallenge-club-4b2656edcbceca0f953707a1c2970f15a3727109.tar.bz2 perlweeklychallenge-club-4b2656edcbceca0f953707a1c2970f15a3727109.zip | |
Merge pull request #2332 from E7-87-83/master
lisp scripts
Diffstat (limited to 'challenge-078')
| -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) |
