[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] destructive sort! really destructive
From: |
Claude Marinier |
Subject: |
Re: [Chicken-users] destructive sort! really destructive |
Date: |
Sat, 24 May 2014 13:17:33 -0400 (EDT) |
User-agent: |
Alpine 2.02 (DEB 1266 2009-07-14) |
On Sat, 24 May 2014, Lo?c Faure-Lacroix <address@hidden> wrote:
I'm not sure if it's how it is supposed to work. I have a list that
looks like this:
'((23 14 19) (28 9 19) (10 10 19) (16 14 18)
(14 8 18) (25 13 18) (13 13 17) (10 7 17)
(27 12 17) (21 12 16) (10 6 16) (5 11 16)
(25 11 15) (6 5 15) (0 10 15) (3 4 14)
(5 3 13) (23 2 12) (16 1 11) (29 0 10)
(15 8 9) (9 5 9) (4 7 8) (17 6 7)
(17 5 6) (28 3 4) (10 0 4) (7 2 3)
(20 1 2) (11 0 1))
When calling this function on this list let say (define a ?)
(sort! a (lambda (x y) (< (car x) (car y))))
Returns the sorted list and then
a is equal to:
((23 14 19) (23 2 12) (25 13 18) (25 11 15) (27 12 17) (28 9 19)
(28 3 4) (29 0 10))
Bonjour,
I decided to play with this but it went wrong.
First, start 'csi'.
address@hidden ~]$ /opt/chicken/bin/csi
CHICKEN
(c) 2008-2014, The Chicken Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.9.0rc1 (rev 3cf1967)
linux-unix-gnu-x86 [ manyargs dload ptables ]
compiled 2014-04-17 on hd-t1179cl (Linux)
; loading /home/claude/.csirc ...
; loading /opt/chicken/lib/chicken/7/parley.import.so ...
; loading /opt/chicken/lib/chicken/7/chicken.import.so ...
; loading /opt/chicken/lib/chicken/7/data-structures.import.so ...
; loading /opt/chicken/lib/chicken/7/extras.import.so ...
; loading /opt/chicken/lib/chicken/7/ports.import.so ...
; loading /opt/chicken/lib/chicken/7/posix.import.so ...
; loading /opt/chicken/lib/chicken/7/srfi-1.import.so ...
; loading /opt/chicken/lib/chicken/7/srfi-13.import.so ...
; loading /opt/chicken/lib/chicken/7/srfi-18.import.so ...
; loading /opt/chicken/lib/chicken/7/stty.import.so ...
; loading /opt/chicken/lib/chicken/7/srfi-69.import.so ...
; loading /opt/chicken/lib/chicken/7/foreign.import.so ...
; loading /opt/chicken/lib/chicken/7/foreigners.import.so ...
; loading /opt/chicken/lib/chicken/7/parley.so ...
; loading /opt/chicken/lib/chicken/7/stty.so ...
Define the list.
#;1>(define a
'((23 14 19) (28 9 19) (10 10 19) (16 14 18)
(14 8 18) (25 13 18) (13 13 17) (10 7 17)
(27 12 17) (21 12 16) (10 6 16) (5 11 16)
(25 11 15) (6 5 15) (0 10 15) (3 4 14)
(5 3 13) (23 2 12) (16 1 11) (29 0 10)
(15 8 9) (9 5 9) (4 7 8) (17 6 7)
(17 5 6) (28 3 4) (10 0 4) (7 2 3)
(20 1 2) (11 0 1))
)
Display the list.
#;2>(display a)
This produces an endlessly repeating stream of errors. Capturing it was
"interesting".
Error: (substring) out of range
0
-32
Call history:
parley.scm:285: loop
parley.scm:284: reverse
list->string
parley.scm:284: string-split
parley.scm:507: read-raw
parley.scm:476: call-with-current-continuation
parley.scm:478: prompt-loop
parley.scm:419: refresh-line
parley.scm:140: ##sys#call-with-values
parley.scm:141: terminal-size
parley.scm:386: -
parley.scm:389: -
parley.scm:390: floor
parley.scm:392: min
parley.scm:394: modulo
parley.scm:395: substring <--
((23 14 19) (28 9 19) (10 10 19) (16 14 18) (14 8 18) (25 13 18)
(13 13 17) (10 7 17) (27 12 17) (21 12 16) (10 6 16) (5 11 16)
(25 11 15) (6 5 15) (0 10 15) (3 4 14) (5 3 13) (23 2 12) (16 1 11)
(29 0 10) (15 8 9) (9 5 9) (4 7 8) (17 6 7) (17 5 6) (28 3 4)
(10 0 4) (7 2 3) (20 1 2) (11 0 1))
Version 4.8.0.5 does the same.
Compiling is OK. Here is the source file:
(define a
'((23 14 19) (28 9 19) (10 10 19) (16 14 18)
(14 8 18) (25 13 18) (13 13 17) (10 7 17)
(27 12 17) (21 12 16) (10 6 16) (5 11 16)
(25 11 15) (6 5 15) (0 10 15) (3 4 14)
(5 3 13) (23 2 12) (16 1 11) (29 0 10)
(15 8 9) (9 5 9) (4 7 8) (17 6 7)
(17 5 6) (28 3 4) (10 0 4) (7 2 3)
(20 1 2) (11 0 1))
)
(display a)
(newline)
Compile and run.
address@hidden scheme]$ csc -o test list-of-triplets.scm
address@hidden scheme]$ ./test
((23 14 19) (28 9 19) (10 10 19) (16 14 18) (14 8 18) (25 13 18)
(13 13 17) (10 7 17) (27 12 17) (21 12 16) (10 6 16) (5 11 16)
(25 11 15) (6 5 15) (0 10 15) (3 4 14) (5 3 13) (23 2 12) (16 1 11)
(29 0 10) (15 8 9) (9 5 9) (4 7 8) (17 6 7) (17 5 6) (28 3 4)
(10 0 4) (7 2 3) (20 1 2) (11 0 1))
OS is
Linux hibou 3.2.0-4-686-pae #1 SMP Debian 3.2.57-3+deb7u1 i686 GNU/Linux
Something is broken. Is it my build or Chicken itself?
Merci.
--
Claude Marinier