freenode/#lisp - IRC Chatlog
Search
16:29:57
nij
Now the only problem is to lispily format a long list such that the length of each row isn't more than, say, 80.
16:53:31
Nilby
I usually use with-output-to-string in a loop. You could also just output to a string with a fill-pointer.
16:56:30
Nilby
e.g. (let ((s (make-array 0 :element-type 'character :fill-pointer t))) (loop for i from 0 to 10 do (format s "salmon")) s)
17:42:32
shka_
(with-output-to-string (stream) (loop for i from 0 to 10 do (format stream "salmon")))
17:42:39
shka_
jmercouris: reduce is a really bad option here since concat will allocate new copy fo string for each element of the sequence being reduced
17:43:07
shka_
also, technically speaking function passed to reduce should handle being called with 0, 1 or 2 arguments
17:46:17
Nilby
The format one is slower actually than the reduce, but takes much less memory, but the with-output-to-string seems the fastest.
17:49:02
_death
shka: they will never be called with one argument, and you can provide an initial value to ensure they will never be called with no arguments
17:50:04
Alfr_
... or ensure that sequence is never empty, then it won't be called with zero arguments as well.
18:32:10
jasom
with-output-to-string is definitely the idiomatic way to accumulate values into a string.
18:36:32
fiddlerwoaroof
jmercouris: (reduce (lambda (acc next) (format acc "~a" next)) seq :initial-value (make-array 10 :element-type 'character :fill-pointer 0))
18:37:27
fiddlerwoaroof
Reduce is just a loop with an accumulator, so if you control the initial value there's no reason not to mutate it :)
18:38:25
fiddlerwoaroof
If some FP purist complains, just explain that you're using dynamic linear types.
18:38:36
jasom
fiddlerwoaroof: but at that point why use reduce at all, and just put the mutation in the loop body?
19:08:03
wanko
hello, is it okay to ask beginner scheme questions here, or is there a different channel for that?
19:46:43
dbotton
I assume there is no way in lisp to "use" the sequence passed to subseq as part of an expression to calculate end?
19:47:57
jasom
dbotton: I think various utility libraries let you do python-style passing of negative values for subseq ranges. I can't speak to the quality of any of them though.
19:48:22
Xach
dbotton: (defun trim-last-char (s) (subseq s 0 (1- (length s))) is what i might do if i didn't a cluttered expression
20:00:29
jasom
fiddlerwoaroof: but the original question was phrased in a way that assumes the sequence was of at least length 1
20:06:30
Bike
oh, i thought maybe sbcl might do its magic shrink-vectors-even-if-they-don't-have-fill-pointers thing but i guess it's too messy
20:54:36
dbotton
From a GitHub discussion "Clog is totally fun. It made me re-start learning Lisp." Thought I would share for those that help me
21:00:09
alanz
I know, which is why I am speaking up. I love seeing it come together bit by bit, and appreciate the effort you put in to making clear, understandable code
21:13:48
alanz
dbotton, I got as far as using your tutorial 13 as a base. Now scratching my head wondering what the next thing to do is. The general idea is to help managing entries to https://www.facebook.com/saflowerunion/posts/4851293668246422
21:18:54
dbotton
Since an admin tool, maybe consider using tutorial 22 as your base and have a nice look desktop motif
21:20:30
alanz
thanks, will do so. I also see myself interacting with the local file system, and showinng pictures. So the desktop one is definitely a good basis
21:21:53
alanz
its going to be slow though, this is a back-burner project for me, which I am using to learn cl at the same time (from some experience with elisp)
21:26:08
dbotton
And that is why my plan is to do a CLOG Lisp tutorial, it is a cool way for people to learn because they see results right away
21:27:25
dbotton
Still hope someone with better language skills takes me up on project :) but if not I will do
21:35:52
alanz
you are doing fine, as far as I can see. Being active and enthusiastic is the most important thing, I reckon
1:11:50
charles`
can't they just be macros? that then (sometimes) expand into implementation specific magic
1:26:09
_death
the self-modifying code issue is interesting.. not just because it uses "bletcherous" jargon, but also because it mentions "displacing macros", which I will now try to find more about.. my guess is that they "patch" the form in place with their expansion