google / lisp-koans

Common Lisp Koans is a language learning exercise in the same vein as the ruby koans, python koans and others. It is a port of the prior koans with some modifications to highlight lisp-specific features. Structured as ordered groups of broken unit tests, the project guides the learner progressively through many Common Lisp language features.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in vectors.lsp

jboyens opened this issue · comments

Great work, but I think I found an error:

(assert-equal #*0011 (make-array '4 :element-type 'bit))

(make-array '4 :element-type 'bit) makes something like #*0000 not #*0011

Same here.
Should be #*0000

I wonder if they meant the line to read

(assert-equal ____ (make-array '4 :element-type 'bit :initial-contents '(0 0 1 1)))

This would make it easier to figure out the answer to list-to-bit-vector part.

This test invokes undefined behaviour.

CLHS MAKE-ARRAY states:

If initial-element is not supplied, the consequences of later reading an uninitialized element of new-array are undefined unless either initial-contents is supplied or displaced-to is non-nil.

Therefore, (make-array '4 :element-type 'bit) is not guaranteed to return #*0000. According to the standard, it is allowed to return #*1111 as well, as well as any 4-bit combination.