libera/#commonlisp - IRC Chatlog
Search
19:19:04
gilberth
It gets funnier. https://novaspec.org/cl/v_print-circle says "If a user-defined print-object method prints to a stream other than the one that was supplied, then circularity detection starts over for that stream." Doesn't happen with SBCL, CMUCL, or ABCL. <https://termbin.com/504d>
19:28:00
yitzi
gilberth: I'd be surprised if any implementation does that. They all use a single group of dynamic variables to control it. If one implementation is different it could be CLISP. All the other implementations use either the original XP code or CMUCL's rewrite.
19:29:18
HamzaShahid
I wanted to create permutations of a list like (0 1 2) to ((0 1 2) (0 2 1) (1 0 2) (1 2 0) ...) lexecographically
19:40:41
yitzi
I'm not sure about CCL, ECL and ACL. CLASP is based on ECL it doesn't attempt make circle detection stream specific.
19:44:36
gilberth
So with CMUCL^SBCL, ECL, ABCL circle printing also is ineffective when you print somewhere else. Again CCL, CLISP, ACL getting it right. IMHO.
19:49:53
pjb
HamzaShahid: it's the same code to create permutations of 2 values as for n values! Just modify my function (trivially).
19:50:54
pjb
HamzaShahid: (defun all-symbol-combinations (p n) (if (zerop n) '(()) (let ((rests (all-bit-combinations (- n 1)))) (mapcan (lambda (bit) (mapcar (lambda (rest) (cons bit rest)) rests)) (iota p))))) (all-symbol-combinations 4 3) #| --> ((0 0 0) (0 0 1) (0 1 0) (0 1 1) (1 0 0) (1 0 1) (1 1 0) (1 1 1) (2 0 0) (2 0 1) (2 1 0) (2 1 1) (3 0 0) (3 0 1) (3 1 0) (3 1 1)) |#
19:51:41
pjb
HamzaShahid: sorry, bad renaming; here it is: (defun all-symbol-combinations (p n) (if (zerop n) '(()) (let ((rests (all-symbol-combinations p (- n 1)))) (mapcan (lambda (bit) (mapcar (lambda (rest) (cons bit rest)) rests)) (iota p))))) (all-symbol-combinations 4 3) #| --> ((0 0 0) (0 0 1) (0 0 2) (0 0 3) (0 1 0) (0 1 1) (0 1 2) (0 1 3) (0 2 0) (0 2 1) (0 2 2) (0 2 3) (0 3 0) (0 3 1) (0 3 2) (0 3 3) (1 0 0) (1 0 1) (1 0 2) (1 0 3) (1 1
19:51:41
pjb
0) (1 1 1) (1 1 2) (1 1 3) (1 2 0) (1 2 1) (1 2 2) (1 2 3) (1 3 0) (1 3 1) (1 3 2) (1 3 3) (2 0 0) (2 0 1) (2 0 2) (2 0 3) (2 1 0) (2 1 1) (2 1 2) (2 1 3) (2 2 0) (2 2 1) (2 2 2) (2 2 3) (2 3 0) (2 3 1) (2 3 2) (2 3 3) (3 0 0) (3 0 1) (3 0 2) (3 0 3) (3 1 0) (3 1 1) (3 1 2) (3 1 3) (3 2 0) (3 2 1) (3 2 2) (3 2 3) (3 3 0) (3 3 1) (3 3 2) (3 3 3)) |#
19:53:30
pjb
HamzaShahid: since it can grow fast, you may want to do it incrementally. have a look at: https://gitlab.com/com-informatimago/com-informatimago/-/blob/master/common-lisp/cesarum/combination.lisp
20:18:42
gilberth
So it looks like SBCL abandoms *print-circle* processing when doing output to another stream altogether, but for the top-level object printed to that other stream. I can see why they have chosen to do so. Watch <https://termbin.com/y6fs>. This time using ~S. When asking for ~20S however, CCL fails to do *print-circle* processing because it first prints the argument to a string.
20:19:43
gilberth
However, completely abandoning *print-circle* may make you face some infinite recursion. I don't like that.
6:09:12
bitblit1
pjb: How would I modify that to make it permutations of a list. I thought of binary but that has repitition?
6:18:16
bitblit1
What is the easy way of grouping a list into sublists for e.g: '(9 2 7 8 4 1 0 4 6 3) in groups of 2 => '((9 2) (7 8) (4 1)...)
6:23:09
bitblit1
Thanks beach However, this is dependent on the cddr function, if we wanted to lets say take pairs of 12 that would be really difficult
6:27:27
bitblit1
beach: I wanted to make something dynamic which pairs depending on a number in this case (list x y z) is also not dependent