Advertisement
Guest User

Untitled

a guest
May 9th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.75 KB | None | 0 0
  1. (defvar color-blocks
  2.   (list '(4/5 "█")
  3.     '(3/5 "▓")
  4.     '(2/5 "▒")
  5.     '(1/5 "░")
  6.     '(0/5 " ")))
  7.  
  8. ;;; I'm trying to make a "selector" macro, where I provice a list
  9. ;;; like above, and compare a number to see if it pases, I want to be
  10. ;;; able to make a cond structure with it, such that it expands to
  11. ;;; (cond
  12. ;;;   ((>= 4/5 number) "█")
  13. ;;;   ...
  14. ;;; for every element in the selector list, thing is am failing quite
  15. ;;; badly at making this :(
  16.  
  17. (defmacro selector (number selectors)
  18.   "Takes a number to compare to and a selectors list composed of a number
  19. to compare to and a return value"
  20.   (cond
  21.     `(loop for i from 0 to (list-length selectors)
  22.     :collect
  23.     (let ((sel (nth i selectors)))
  24.       '((>= number ,(first sel)) ,(second sel))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement