Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defvar color-blocks
- (list '(4/5 "█")
- '(3/5 "▓")
- '(2/5 "▒")
- '(1/5 "░")
- '(0/5 " ")))
- ;;; I'm trying to make a "selector" macro, where I provice a list
- ;;; like above, and compare a number to see if it pases, I want to be
- ;;; able to make a cond structure with it, such that it expands to
- ;;; (cond
- ;;; ((>= 4/5 number) "█")
- ;;; ...
- ;;; for every element in the selector list, thing is am failing quite
- ;;; badly at making this :(
- (defmacro selector (number selectors)
- "Takes a number to compare to and a selectors list composed of a number
- to compare to and a return value"
- (cond
- `(loop for i from 0 to (list-length selectors)
- :collect
- (let ((sel (nth i selectors)))
- '((>= number ,(first sel)) ,(second sel))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement