freenode/#lisp - IRC Chatlog
Search
6:00:20
no-defun-allowed
GCL isn't a conforming Common Lisp implementation, and it doesn't have a native code compiler that makes JVM weenies fear for their lives[citation needed].
6:01:11
no-defun-allowed
GCL, if it is supposed to be a Common Lisp implementation, has to be a Lisp-2. There should be zero difference in semantics when running portable CL programs on conforming implementations.
6:02:08
jackdaniel
dialectic: https://common-lisp.net/project/ecl/static/quarterly/img/vol4/all-hierarchy.png
6:02:36
no-defun-allowed
Kyoto implemented CLtL 1 (which is not ANSI CL), Austin-Kyoto was an improved fork, then GCL was derived from AK.
6:04:31
jackdaniel
probably I should paint some green blocks yellow and vice versa after 3y, but nvm that
6:06:14
jackdaniel
there is also some inaccuracy in the obsolete section, I remember being called for making the link Lisp-to-C towards Star Sapphire
13:14:49
Bike
okay. true. so you can write an iteration over list elements. do you want me to write it for you or are you capable.
13:15:14
kuribas
Bike: I am capable thank you. Just wanted to know if lisp has something standard defined
13:52:56
pjb
I was thinking about (defun take (n list) (loop repeat n for current := list :then (rest current) collect (first current))) but then (take 2 '(1)) #| --> (1 nil) |#
16:37:06
dim
just noticed that the topic here says SBCL 1.4.16 is current, but I see _The most recent version is SBCL 1.5.4, released June 29, 2019_ over at sbcl.org... do we want to maintain the topic version numbers?
16:39:08
ck_
I'd put the urls in the topic if they fit -- I'd be surprised if anybody depended on the topic of #lisp on freenode for their release updates
16:40:12
ck_
or maybe those are there in case of rhetorical emergencies. "What version do you run? I'm sorry. We only discuss sbcl 1.4.16 in here!"
16:55:36
aeth
pjb: ggole has the correct answer. LOOP will terminate at the shorter iteration, so it will either repeat n times or for loop the length of the list, whichever ends first
17:12:18
aeth
if you wanted to have a filler value you'd have to let the user specify a default because the user might have a list of NILs as the input!
17:17:40
aeth
I think the best TAKE in CL style, though, would be sequence-generic and have an ETYPECASE with Bike's (subseq sequence 0 (min n (length sequence))) solution for non-list sequences (ideally vectors, but a user-extensible sequence might be used).
17:28:33
aeth
(defun take (n sequence) (check-type n fixnum) (etypecase sequence (list (loop :repeat n :for item :in sequence :collect item)) (sequence (subseq sequence 0 (min n (length sequence))))))
17:32:43
aeth
You actually don't want to check for fixnum. A positive fixnum type will probably work, although technically there are some very large positive fixnums that will be invalid. Not really an issue since you'll run out of memory first. Either way, the check-type will actually wind up speeding things up for large enough n because it will remove the generic arithmetic.