triffid has quit [Remote host closed the connection]
vitovan has joined #commonlisp
bilegeek has quit [Quit: Leaving]
dcb has quit [Quit: MSN Messenger 4.0.0]
iisi has quit [Server closed connection]
iisi has joined #commonlisp
bjorkint0sh has joined #commonlisp
bjorkintosh has quit [Ping timeout: 246 seconds]
tyson2 has quit [Remote host closed the connection]
czy has quit [Remote host closed the connection]
habamax has quit [Ping timeout: 264 seconds]
Posterdati has quit [Ping timeout: 264 seconds]
Posterdati has joined #commonlisp
czy has joined #commonlisp
lucasta has quit [Remote host closed the connection]
lucasta has joined #commonlisp
habamax has joined #commonlisp
bjork1intosh has joined #commonlisp
bjorkint0sh has quit [Ping timeout: 240 seconds]
akoana has quit [Ping timeout: 250 seconds]
brettgilio has joined #commonlisp
occ has quit [Ping timeout: 264 seconds]
lucasta has quit [Quit: Leaving]
bjorkint0sh has joined #commonlisp
bjork1intosh has quit [Ping timeout: 246 seconds]
amb007 has quit [Ping timeout: 258 seconds]
amb007 has joined #commonlisp
pranavats has left #commonlisp [Disconnected: Replaced by new connection]
pranavats has joined #commonlisp
occ has joined #commonlisp
bjorkint0sh has quit [Ping timeout: 240 seconds]
<jasonmw>
Hello, I am going through the book 'a gentle introduction to symbolic computation' and came across something I am unsure of. I don't understand why it is behaving this way.
<jasonmw>
One task was to write PREFIX that would return the first n parts of a list. I started with the DO* in case i needed it, otherwise i would just remove the * to make it DO if that is all that was needed. I came up with essentially the same answer but with a difference as below.
<jasonmw>
When it is the DO* the count is out of step by 1 and the code has to cater for that.
<jasonmw>
(defun prefix (n strand)
<jasonmw>
I can't see in the docs why this is the case.
<jasonmw>
So both these functions give the same result but in the DO* i have to use (1- count) instead of just count?
<jasonmw>
I understand why you would use DO* when one var wants to refer to another in the initial bindings but other than that I thought they should behave the same.
<mfiano>
because the lexical variables are bound serially
<mfiano>
if you bind count to 0, then specify that it should have a step of (1+ count), the latter would be expecting `count` to be in an outer scope.
<jasonmw>
i am thinking this over :)
<mfiano>
whereas since do* binds in parallel, the value of count in the preceding binding is referenced, instead of one in an outer scope
<mfiano>
err serial
<mfiano>
when bindings are made in parallel, all values are evaluated before they are placed in their variable.
<mfiano>
when they are made serially, well, you get the idea
<jasonmw>
' all values are evaluated before they are placed in their variable.'
<jasonmw>
this makes sense
<jasonmw>
i knew of one effect but didn't carry that all the way forward to the wider impacts
<jasonmw>
thx!
<mfiano>
Keep in mind, using DO is quite rare. Most people don't even remember how to use it when they do need (or do they?) it
<mfiano>
Just see the preceding discussion in the channel log in the topic
<mfiano>
(or DO*)
<jasonmw>
yes, i am just going through the book learning a bit and hoping to at the end of a few books get an idea what is common practise
<jasonmw>
it is interesting though - sometimes i do a solution to a problem and look at his solution and wonder why he did it like that as it didn't seem to be the best.
<mfiano>
You will find #clschool more helpful also
<mfiano>
This channel assumes some experience
<jasonmw>
thx, i will jump in to that as well, i brought this one up recently just to browse and catch anything interesting
<mfiano>
But some questions are tolerated at times
<jasonmw>
appreciate the answer and clarification on the channel
<beach>
jasonmw: Also, use a paste site, like plaster.tymoon.eu for instance, for code that requires more than one line.
<jasonmw>
will do.
msavoritias has joined #commonlisp
dre has joined #commonlisp
rainthree has joined #commonlisp
overclucker has quit [Ping timeout: 250 seconds]
overclucker has joined #commonlisp
rainthree has quit [Ping timeout: 246 seconds]
resttime has quit [Server closed connection]
resttime has joined #commonlisp
vn36 has joined #commonlisp
amb007 has quit [Ping timeout: 260 seconds]
amb007 has joined #commonlisp
vitovan has quit [Ping timeout: 250 seconds]
shka has joined #commonlisp
ronald has quit [Read error: Connection reset by peer]
ronald has joined #commonlisp
rgherdt has joined #commonlisp
vitovan has joined #commonlisp
ronald has quit [Read error: Connection reset by peer]
ronald has joined #commonlisp
gaze___ has quit [Server closed connection]
vn36 has quit [Ping timeout: 252 seconds]
gaze___ has joined #commonlisp
ec has quit [Remote host closed the connection]
ec has joined #commonlisp
random-jellyfish has quit [Quit: Client closed]
thollief has joined #commonlisp
attila_lendvai has joined #commonlisp
rainthree has joined #commonlisp
amb007 has quit [Ping timeout: 260 seconds]
amb007 has joined #commonlisp
rtypo has joined #commonlisp
igemnace has joined #commonlisp
LW has joined #commonlisp
mm007emko has joined #commonlisp
vn36 has joined #commonlisp
LW has quit [Quit: WeeChat 3.8]
igemnace has quit [Remote host closed the connection]
igemnace has joined #commonlisp
dino_tutter has joined #commonlisp
<ogamita>
jasonmw: your functions are ok, only one thing: you may want to use nreverse here instead of reverse. Since you've built a new list in your function, you can mutate it with nreverse, avoiding to cons new cells. If you use cons (or push) in a loop + nreverse, it's as efficient as if you used a reference to the last cell to create the list in order.
Guest33 has joined #commonlisp
Guest33 has quit [Client Quit]
mgl has joined #commonlisp
<jasonmw>
Thanks, yes it has been mentioned but he doesn't seem to use the most efficient ways in his answers. I suppose at this stage it is just learning the basics but I am pretty keen to see how lispers really code. I have read that dealing with lists as we do through the tutorials is not really how more performant lisp is done.
<beach>
I think many Lispers would use LOOP with COLLECT.
<jasonmw>
I have timed some of my answers against his and in some instances i was consing more than 100% less than the books answer. I can only assume that the books answers are demonstrating something but its not clear as he will do something one way and another in a different way than just presented
<jasonmw>
I have been playing with loop as well but at the moment following the structure of this book. I will be finished with it in a few days and looking for the next one
<beach>
Sure, I was just remarking on your being keen to see how lispers really code.
<jasonmw>
yes :) I think the next book should be one that presents a more realistic approach
<jasonmw>
real world I mean as they wont have to treat me as such a newbie, i hope
<beach>
Depending on what the next one is, of course. PCL is a much better choice than the current one.
jurassic has quit [Ping timeout: 250 seconds]
habamax has quit [Quit: ERC 5.4 (IRC client for GNU Emacs 28.2)]
<jasonmw>
I had a go at practical common lisp and the only reason i didn't finish it is i got sidetracked with this book thinking it might be a good one for the kids so i was doing a demo run
igemnace has quit [Remote host closed the connection]
igemnace has joined #commonlisp
<beach>
"Gentle" was written before the standard was finalized, so as I recall, it may contain code that is not quite conforming.
<ogamita>
jasonmw: You may use local functions to augment your language locally: https://termbin.com/6tvv
<jasonmw>
i got interested in lisp a bit over 30 years ago when I was doing some prolog and had a suscription to a mag called AI Expert, it had a lot of articles about lisp but I didn't have access to a system running lisp. It's taken a few years to tell myself I want to pick up the interest I had back then.
<beach>
jasonmw: Excellent!
<ogamita>
jasonmw: Oh, you should also avoid using NTH or ELT on lists in loops. This makes your code O(n^2) instead of O(n).
<ogamita>
jasonmw: well, 30 years ago was 1993, and there was lisp (and scheme) implementations running on Mac, PC, Amiga! It was the great epoch of clisp on amiga!
<ogamita>
MCL on Mac (ancestor of CCL).
igemnace has quit [Remote host closed the connection]
<jasonmw>
yeah it was just my access to it letting me down - i didn't even have a real prolog (turbo prolog ahem )
igemnace has joined #commonlisp
<jasonmw>
i still have the original manuals 1988 so it says
<jasonmw>
so i was a few years off, always seem to think of myself as a little younger than i must be
igemnace has quit [Remote host closed the connection]
igemnace has joined #commonlisp
<jasonmw>
ogimata: thanks for the code, it certainly has a different feel about it, thats one thing about the books, the styles can seem quite different
igemnace has quit [Remote host closed the connection]
<ogamita>
note the test cases. You must deal with empty or shorter lists, and with 0 or negative n.
igemnace has quit [Remote host closed the connection]
<jasonmw>
thx, yes I agree, the author is being lenient on the cases as far as developing the answers so I have tried to keep them simple and see if I match what his answer is but I am not sure if this is best or just do what I want. The issue being that I dont know if the code i do woulde be considered good style while i assume that the authors is - or that he is demonstrating something. an example - let me paste bin
igemnace has joined #commonlisp
vn36 has quit [Ping timeout: 260 seconds]
vn36 has joined #commonlisp
rainthree has quit [Read error: Connection reset by peer]
<jasonmw>
i did the mapcar, he did the do... i wondered why he did that as we had covered mapcar - but that is the joy of learning from a book that cant explain itself :)
easye has quit [Quit: ERC 5.4 (IRC client for GNU Emacs 28.2)]
azimut_ has quit [Ping timeout: 240 seconds]
pve has joined #commonlisp
<jasonmw>
I think with my experience I can't look too far in to it though, just keep learning and things will fall in to place
akoana has joined #commonlisp
m5zs7k has quit [Ping timeout: 246 seconds]
m5zs7k has joined #commonlisp
Lord_of_Life_ has joined #commonlisp
Lord_of_Life has quit [Ping timeout: 240 seconds]
Lord_of_Life_ is now known as Lord_of_Life
occ has quit [Ping timeout: 264 seconds]
vn36 has quit [Ping timeout: 260 seconds]
habamax has joined #commonlisp
karlosz has joined #commonlisp
Brucio-61 has quit [Ping timeout: 260 seconds]
jurassic has joined #commonlisp
holycow has joined #commonlisp
random-nick has joined #commonlisp
iquites has quit [Server closed connection]
iquites has joined #commonlisp
kevingal has joined #commonlisp
karlosz has quit [Quit: karlosz]
gendl__ has quit [Server closed connection]
gendl__ has joined #commonlisp
contrapunctus has quit [Ping timeout: 240 seconds]
contrapunctus has joined #commonlisp
mi6x3m has joined #commonlisp
<mi6x3m>
hey, what is common lisp terminology for a function that returns a function which generates the next element of a logical sequence
<mi6x3m>
like
<mi6x3m>
(defun gen-counter (limit) <return function that upon successive calls returns numbers from 1 to limit>
<hayley>
Sounds like an "iterator", e.g. WITH-HASH-TABLE-ITERATOR and WITH-PACKAGE-ITERATOR
<mi6x3m>
this is just an example i'm returning fields from a line of text
<mi6x3m>
yeah, it seems like iterator is the thing
LispTyro has quit [Ping timeout: 250 seconds]
LispTyro has joined #commonlisp
occ has joined #commonlisp
rendar has quit [Ping timeout: 250 seconds]
waleee has joined #commonlisp
luna-is-here has quit []
luna-is-here has joined #commonlisp
Brucio-61 has joined #commonlisp
vitovan has quit [Quit: leaving]
Brucio-61 has quit [Ping timeout: 240 seconds]
Brucio-61 has joined #commonlisp
habamax has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.0.92)]
holycow has quit [Quit: leaving]
IUSR has quit [Server closed connection]
IUSR has joined #commonlisp
johnjaye has quit [Ping timeout: 250 seconds]
johnjaye has joined #commonlisp
waleee has quit [Ping timeout: 240 seconds]
modula has joined #commonlisp
defaultxr has quit [Ping timeout: 250 seconds]
cage has joined #commonlisp
rainthree3 has joined #commonlisp
rainthree has quit [Ping timeout: 250 seconds]
mi6x3m has quit [Ping timeout: 240 seconds]
dre has quit [Ping timeout: 240 seconds]
mi6x3m has joined #commonlisp
johnjaye has quit [Ping timeout: 260 seconds]
johnjaye has joined #commonlisp
Newbie has joined #commonlisp
Lord_of_Life has quit [Ping timeout: 250 seconds]
Lord_of_Life has joined #commonlisp
semarie has quit [Ping timeout: 250 seconds]
semarie has joined #commonlisp
jwd has joined #commonlisp
mrcom_ has joined #commonlisp
mrcom has quit [Read error: Connection reset by peer]