freenode/#lisp - IRC Chatlog
Search
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.
18:10:00
interruptinuse
asdf manual "6.3.12 Feature dependencies" says :feature cannot be used to make the system depend on a specific impl feature
18:11:00
interruptinuse
my current options are: (1) to :if-feature the package.lisp file, which is ugly, or (2) to detect the feature myself in package.lisp or something and fail at compile time
18:11:51
interruptinuse
basically i'd lik to say, as declaratively as possible, "this .asd is for SBCL only"
18:19:14
oni-on-ion
interruptinuse, yeah, looks like (1) - https://common-lisp.net/project/asdf/asdf/Common-attributes-of-components.html#Common-attributes-of-components
22:46:43
phf
hello, does anybody have a backup of https://github.com/pyb/zen (it's the common lisp implementation of x11 server, targeting opengl)?
23:19:19
oni-on-ion
phf, sounds like it would be a nice project; i tried searching for it and could not find anything