libera/#commonlisp - IRC Chatlog
Search
8:36:09
jackdaniel
that's not very conservative though, I'd rather fix the description of ":test" to explicitly allow nil
10:17:44
beach
I fear that someone who reads the dictionary entry for RESTART-BIND or RESTART-CASE might create a TEST-FUNCTION that does not work if passed NIL as an argument.
14:17:01
beach
What standard special forms or macros have a list of "bindings" other than LET, LET*, HANDLER-BIND, and RESTART-BIND?
14:18:35
beach
I mean syntactically, so that some part of the form can be identified as such a list of bindings.
14:22:44
ogamita
Also, binding is something that is established at run-time, so I wouldn't make such a difference between progv and let…
14:23:20
beach
For context, I am working on Iconoclast, which is a library defining ASTs for standard special forms and macros, and I am trying to identify reasonable mixin classes. That's why I am interested only in operators where the list of bindings is syntactically apparent.
14:25:34
bike
the format of the bindings is different for a lot of these, though. like LET is symbol | (symbol [value]), which is not what handler-bind or flet have.
14:38:29
beach
The idea is to extract certain features to mixin classes to avoid code duplication. Like bindings, declarations, documentation, body, clauses, ...
20:11:07
HamzaShahid
I was solving another projecteuler problem and somehow managed to make it a binary addition problem
20:11:38
HamzaShahid
All I want now is to have a list of lists containing each digit of a binary number going from 000 to 111
20:13:43
HamzaShahid
but it should be generated dynamically be saying how many digits of binary to calculate from. Any idea on how to add and operate on raw binary in common lisp. Any help would be greatly appreciated
20:15:06
HamzaShahid
PS. I know there are libraries like cl-binary but I want to do it with raw common lisp for educational purposes
20:26:16
pjb
HamzaShahid: (defun all-bit-combinations (n) (if (zerop n) '(()) (let ((rests (all-bit-combinations (- n 1)))) (mapcan (lambda (bit) (mapcar (lambda (rest) (cons bit rest)) rests)) '(0 1))))) (mapcar #'all-bit-combinations '(0 1 2 3)) #| --> ((nil) ((0) (1)) ((0 0) (0 1) (1 0) (1 1)) ((0 0 0) (0 0 1) (0 1 0) (0 1 1) (1 0 0) (1 0 1) (1 1 0) (1 1 1))) |#