derelict has joined #commonlisp
taiju has quit [Ping timeout: 258 seconds]
lisp123 has joined #commonlisp
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
lisp123 has quit [Ping timeout: 244 seconds]
char has quit [Ping timeout: 272 seconds]
taiju has joined #commonlisp
char has joined #commonlisp
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
random-nick has quit [Ping timeout: 258 seconds]
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
char has quit [Ping timeout: 268 seconds]
klltkr_ has quit [Ping timeout: 272 seconds]
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
waleee has quit [Ping timeout: 272 seconds]
bilegeek has joined #commonlisp
prxq_ has joined #commonlisp
prxq has quit [Ping timeout: 258 seconds]
IAmRasputin has joined #commonlisp
IAmRasputin has quit [Ping timeout: 265 seconds]
taiju has quit [Remote host closed the connection]
taiju has joined #commonlisp
azimut has quit [Ping timeout: 244 seconds]
azimut has joined #commonlisp
tyson2 has quit [Read error: Connection reset by peer]
<beach> Good morning everyone!
derelict has quit [Ping timeout: 250 seconds]
beach` has joined #commonlisp
beach has quit [Ping timeout: 268 seconds]
beach` is now known as beach
akoana has quit [Quit: leaving]
dsk has joined #commonlisp
lisp123 has joined #commonlisp
Lord_of_Life_ has joined #commonlisp
Lord_of_Life has quit [Ping timeout: 265 seconds]
lisp123 has quit [Remote host closed the connection]
Lord_of_Life_ is now known as Lord_of_Life
lisp123 has joined #commonlisp
yp has joined #commonlisp
yp is now known as Guest7506
Guest7593 has quit [Ping timeout: 246 seconds]
aeth_ has joined #commonlisp
lisp123 has quit [Ping timeout: 268 seconds]
[deleted] has quit [Read error: Connection reset by peer]
livoreno has joined #commonlisp
hendursaga has quit [Remote host closed the connection]
hendursaga has joined #commonlisp
char has joined #commonlisp
phantomics has joined #commonlisp
lisp123 has joined #commonlisp
Mandus has quit [Ping timeout: 265 seconds]
Mandus has joined #commonlisp
lad_ has quit [Ping timeout: 244 seconds]
Mandus has quit [Ping timeout: 258 seconds]
Mandus has joined #commonlisp
lad_ has joined #commonlisp
IAmRasputin has joined #commonlisp
IAmRasputin has quit [Ping timeout: 265 seconds]
lisp123 has quit [Ping timeout: 258 seconds]
sjl has joined #commonlisp
aeth has quit [Quit: ...]
wilfred has joined #commonlisp
aeth has joined #commonlisp
char has quit [Ping timeout: 265 seconds]
aeth has quit [Ping timeout: 258 seconds]
aeth has joined #commonlisp
<susam> beach: Good morning!
<susam> Good morning, everyone!
taiju has quit [Ping timeout: 272 seconds]
<beach> Hello susam.
taiju has joined #commonlisp
lad_ has quit [Ping timeout: 265 seconds]
varjag has joined #commonlisp
treflip has joined #commonlisp
selwyn has joined #commonlisp
shka has joined #commonlisp
selwyn has quit [Read error: Connection reset by peer]
pve has joined #commonlisp
blihp has quit [Quit: Leaving]
bilegeek has quit [Quit: Leaving]
CrashTestDummy3 has joined #commonlisp
CrashTestDummy2 has quit [Ping timeout: 268 seconds]
amb007 has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
varjag has quit [Ping timeout: 258 seconds]
<coat> Is there a function that can test if all characters of a string are digits?
<aeth> (every #'digit-char-p "1234")
<beach> So, no. :)
<coat> aeth: thanks
<coat> is #' necessary in #'digit-char-p. I see 'digit-char-p also works.
<moon-child> (lambda (x) (every #'digit-char-p x)) :)
<beach> coat: Common Lisp is wonderful in that, instead of containing a function for every possible special case, it contains all the building blocks to make such functions yourself.
hendursa1 has joined #commonlisp
<aeth> coat: For built-ins? Shouldn't matter. For user-defined functions? There can be a distinction if it gets redefined. (CLs can prevent things in the COMMON-LISP package from being redefined)
<moon-child> beach: eh...I know of few languages for which that's not the case
<moon-child> discounting, say, brainfuck
<beach> coat: #'digit-char-p is preferable. You then clearly tell the person reading your code that it is the function you are passing, rather than the symbol.
<coat> beach: thanks
<moon-child> and I do wish cl had better tools (built-in) for tacit programming. It is cumbersome to write the above lambda, rather than (e.g.) (partial #'every #'digit-char-p)
<beach> moon-child: Oh? From the videos of C++ "standardization" that I have watched. The process is mainly about introducing more special cases every iteration.
<aeth> moon-child: beach is right, some languages love special cases, e.g. sum() is very common
hendursaga has quit [Ping timeout: 244 seconds]
<aeth> at least, when we're talking about how to do simple tasks on sequences, which is the topic
<moon-child> sure, but in few languages can you not write (reduce #'+)
<pjb> coat: (ignore-errors (parse-integer "123" :junk-allowed nil)) #| --> 123 ; 3 |# (ignore-errors (parse-integer "1x3" :junk-allowed nil)) #| --> nil ; #<ccl::parse-integer-not-integer-string #x3020036F316D> |#
<moon-child> cute
<pjb> that said, it may be less efficient, and on long strings, in both cases.
<aeth> moon-child: but it winds up with what's idiomatic in the language... and in particular, what's optimal (since if a sum() or .sum() is built in, that's probably faster than their equivalent of (reduce #'+ ...) while if it's not built in, then the implementation will try to optimize (reduce #'+ ...) more)
<coat> What is the difference between char and schar? http://www.lispworks.com/documentation/lw50/CLHS/Body/f_char_.htm is not easy to understand for me.
<aeth> it's saying (through several hyperlinks) that schar only works on simple strings, which are simple-strings, i.e. http://www.lispworks.com/documentation/lw50/CLHS/Body/t_smp_st.htm#simple-string
<aeth> these strings are 1D simple character arrays
<moon-child> aeth: the particular case of 'sum' is a bad one, as it's likely to have different semantics: reducing floating-point error. More generally, compilers recognizing specific idiomatic forms (such as (reduce #'+)) doesn't scale outside of apl. More interesting things like loop unrolling and autovectorization any compiler worth its salt will do anyway, given the opportunity
<coat> aeth: what is a non-simple string?
<aeth> coat: most commonly, an adjustable string buffer
CrashTestDummy2 has joined #commonlisp
<aeth> (make-array 8 :element-type 'character :adjustable t :fill-pointer 0)
<aeth> then (vector-push-extend char that-non-simple-string)
<beach> coat: The standard is very clear with its definition of SIMPLE for arrays, but it leaves a lot of decisions to the implementation when it comes to non-SIMPLE.
<aeth> but, yes, there are other ways to get non-simple-strings, e.g. displaced arrays
<beach> ::clhs simple-array
<beach> aeth: The standard allows for all strings to be simple.
CrashTestDummy3 has quit [Ping timeout: 258 seconds]
<pjb> beach: literal strings?
<beach> coat: See the definition of simple-array.
<pjb> beach: I don't see how the standard can forbid: (make-array 8 :element-type 'character :adjustable t :fill-pointer 0)
<pjb> or can let implementations to forbid it.
<beach> pjb: It can't. What makes you think I implied that?
<coat> aeth: beach: thanks!
trocado has quit [Ping timeout: 265 seconds]
<beach> The standard says: "The type of an array that is not displaced to another array, has no fill pointer, and is not expressly adjustable is a subtype of type simple-array."
<beach> But it doesn't say that the other types of arrays are non-simple.
<pjb> Oh, ok. But then it doesn't say that simple-array have to be simple, ie. have to not be displaced, have no fill pointer or cannot be expressly adjustable.
<pjb> If there are only simple-arrays…
IAmRasputin has joined #commonlisp
<beach> Right, it has no opinion about that direction of the implication arrow.
<coat> can this code be made simpler? https://plaster.tymoon.eu/view/2514 - I have repeated (char s n) calls. is there a way to put all the indices in the list, iterate over those indicies and collect (char s i) instead?
<beach> pjb: Though the standard does not define "simple" that way.
<beach> coat: (loop for i in '(0 1 2 ....) collect (char s i))
<pjb> (coerce "1000-2000-30" 'list) #| --> (#\1 #\0 #\0 #\0 #\- #\2 #\0 #\0 #\0 #\- #\3 #\0) |#
<coat> beach: thanks
<pjb> coat: ^
<beach> Pleasure.
<beach> pjb: That is not what was asked for.
IAmRasputin has quit [Ping timeout: 252 seconds]
<coat> pjb: thanks! that would be useful if I wanted all characters. but I want to choose which indices I want so the LOOP solution is more useful for my specific problem.
<beach> pjb: Note that 9 was missing.
<pjb> ok.
<pjb> (let ((string "1000-2000-30")) (coerce (remove #\- string) 'list)) #| --> (#\1 #\0 #\0 #\0 #\2 #\0 #\0 #\0 #\3 #\0) |#
aeth_ has quit [Quit: ...]
CrashTestDummy3 has joined #commonlisp
CrashTestDummy2 has quit [Ping timeout: 265 seconds]
wheelsucker has quit [Remote host closed the connection]
wheelsucker has joined #commonlisp
_death has quit [*.net *.split]
adeht has joined #commonlisp
CrashTestDummy2 has joined #commonlisp
lisp123 has joined #commonlisp
CrashTestDummy3 has quit [Ping timeout: 268 seconds]
wilfred has quit [Quit: Connection closed for inactivity]
lisp123 has quit [Ping timeout: 252 seconds]
jemoka has quit [*.net *.split]
hirez has quit [*.net *.split]
spacebat1 has quit [*.net *.split]
sukaeto has quit [*.net *.split]
markasoftware has quit [*.net *.split]
sukaeto has joined #commonlisp
markasoftware_ has joined #commonlisp
jemoka_ has joined #commonlisp
hirez- has joined #commonlisp
spacebat1 has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
trocado has joined #commonlisp
lotuseater has joined #commonlisp
Inline has quit [Quit: Leaving]
trocado has quit [Ping timeout: 252 seconds]
Inline has joined #commonlisp
silasfox has joined #commonlisp
Inline has quit [Remote host closed the connection]
Inline has joined #commonlisp
frgo has quit [Remote host closed the connection]
frgo has joined #commonlisp
Inline has quit [Remote host closed the connection]
Inline has joined #commonlisp
trocado has joined #commonlisp
<coat> is there a function that take can take all elements of list *b* and append it to list *a*. For example, (defparameter *a* (list 10 20 30)) (defparameter *b* (list 40 50)). I need (some-func *a* *b*) such that the result would be *a* = (10 20 30 40 50)?
IAmRasputin has joined #commonlisp
<shka> coat: yes
<shka> append :D
waleee has joined #commonlisp
<coat> shka: append does not seem to modify *a*. It returns a new list for the result.
<shka> ah
<shka> ok
<shka> use this
<shka> take a look at the example
<coat> shka: thanks. this works.
<shka> also, note that destructive modification of lists is perhaps not the best idea if said list (or part of it) has any chance of being shared
<shka> because bugs will be hilarious
IAmRasputin has quit [Ping timeout: 272 seconds]
<kakuhen> (format nil "good night")
kakuhen has quit [Quit: Leaving...]
amb007 has quit [Ping timeout: 268 seconds]
hendursa1 has quit [Ping timeout: 244 seconds]
tyson2 has joined #commonlisp
amb007 has joined #commonlisp
hendursa1 has joined #commonlisp
kevingal has joined #commonlisp
<coat> what does 'n' mean in 'nconc'? concatenation of n items?
<edgar-rft> non-destructive
<edgar-rft> nonsense, non-consing by using destructive pointer manipulatiopn
<edgar-rft> append creates a new list, nconc modifies the pointers in the cdr cells
<edgar-rft> therefore nconc does not allocate new cons cells
amb007 has quit [Ping timeout: 272 seconds]
amb007 has joined #commonlisp
random-nick has joined #commonlisp
<edgar-rft> same is true for other 'n' functions, e.g. reverse vs. nreverse
kevingal has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
<coat> edgar-rft: thanks
<beach> coat: You may have some interesting surprises with NCONC.
<beach> coat: I recommend using append instead, and assign to the variable.
<coat> beach: Is performance hit not a concern in append?
lisp123 has quit [Ping timeout: 272 seconds]
<coat> beach: Is the surprise about (nconc a b) regarding the fact that some other variable may be referring to 'a' and might be expecting it to not change?
<beach> coat: Both are O(n) in terms of the length of the first list.
<beach> That is one.
<beach> Here is another:
<beach> Consider (defparameter *l1* (list)) (defparameter *l2* (list 11 12))
<beach> What do you think *l1* contains after doing (nconc *l1* *l2*)?
<coat> (list l1 l2)?
<beach> That would be the numbers eleven and twelve in *l2*.
<coat> oops, those were eleven and twelve
<coat> (list 11 12)?
<beach> So you expect *l1* to have the value (11 12). And you would be wrong.
<beach> Hence my warning.
<coat> thanks
<beach> Sure.
<beach> So do (setf *l1* (append *l1* *l2*)) instead.
<beach> And forget about NCONC until you understand what it does.
<beach> ... and until you understand how lists work in Common Lisp.
<beach> coat: Also, a piece of general advice: Do not worry about performance unless your application needs to be faster than it is. And then, only consider parts of the application that are bottlenecks in terms of performance.
<beach> coat: Worry about your algorithms and data structures in terms of asymptotic complexity as usual.
derelict has joined #commonlisp
amb007 has quit [Ping timeout: 272 seconds]
<coat> beach: thanks for the advice
<beach> Sure.
<coat> which is better to use in code? equalp or string=
<coat> assuming comparing strings only
<beach> coat: There is a very general rule in programming, and that is, use the most specific construct that will get the job done.
CrashTestDummy3 has joined #commonlisp
<coat> so string=
<beach> If that gets the job done, then yes.
<coat> why are there so many equal functions in CLHS? it is quite confusing while programming and need to check the CLHS again and again
<beach> coat: Have you programmed in other languages before?
<coat> is there a shortcut to look up function documentation in SLIME? say I want to see what equal does in SLIME itself without opening the browser
<coat> beach: learnt C and Python. but done some real projects in Python only
<beach> You can open the Common Lisp HyperSpec page in Emacs.
amb007 has joined #commonlisp
CrashTestDummy2 has quit [Ping timeout: 268 seconds]
<susam> coat: There are two things I use. C-c C-d d to describe symbol. C-c C-d h to open CLHS in a web browser.
Inline has quit [Remote host closed the connection]
Inline has joined #commonlisp
<coat> susam: thanks
<beach> coat: What material did you use to learn to program?
<coat> beach: k&r for C. python.org tutorial for python
<beach> I see. So you are self-taught?
<coat> beach: yes
<coat> beach: but I understand your point about asymptotic complexity. you mean terms of big oh notation, right?
<beach> I mean, those are both language specific resources, and they probably wouldn't cover rules like the one I just cited.
<beach> coat: Yes, and that's yet another domain, also independent of any language.
Inline has quit [Remote host closed the connection]
Inline has joined #commonlisp
<beach> coat: Part of the reason Common Lisp has so many operators is historical. But then, most people complain that it doesn't have enough.
<coat> beach: do you recommend any good source to learn programming from?
Inline has quit [Remote host closed the connection]
<beach> coat: But here is another general rule of programming: The smaller the language, the more code you have to write yourself, and you often need to do it differently for each project, and certainly in a way incompatible with what other people do.
<beach> ... like object-oriented programming in early Scheme for instance.
Inline has joined #commonlisp
<beach> coat: I would have to think about that and look around. I haven't had to do that for a very long time.
<coat> beach: how did you do learn to program when you did?
<beach> coat: I had some very good teachers at the university, and then I studied a lot myself.
taiju has quit [Ping timeout: 265 seconds]
<beach> Teachers like Erik Sandewall and Anders Haraldson.
<coat> beach: wow! that's nice
<beach> coat: You can learn a lot from people like Robert C Martin (a.k.a. Uncle Bob). He comes across as a bit weird if you watch his "clean code" videos, but he actually knows what he is talking about.
amb007 has quit [Ping timeout: 268 seconds]
<beach> He has also written several books, of course, in case you prefer to read.
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 265 seconds]
cross has quit [Quit: leaving]
waleee has quit [Ping timeout: 250 seconds]
cross has joined #commonlisp
amb007 has joined #commonlisp
cross has quit [Quit: leaving]
cross has joined #commonlisp
cross has quit [Client Quit]
cross has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
<shka> coat: simply put, don't mix destructive and non-destructive data structures
<shka> and lists should be most of the time considered to be non-destructive
taiju has joined #commonlisp
amb007 has joined #commonlisp
char has joined #commonlisp
Equill has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
<Josh_2> 'ello 'ello
<Josh_2> You are correct this fella is an odd ball beach but I am a big fan of the eccentric
silasfox has quit [Ping timeout: 250 seconds]
amb007 has quit [Ping timeout: 272 seconds]
<beach> Uncle Bob?
<beach> Yes, I didn't take him seriously at first, but I have changed my mind since.
silasfox has joined #commonlisp
<Josh_2> Yes Uncle Bob
cage has joined #commonlisp
adeht is now known as _death
Nilby has joined #commonlisp
silasfox has quit [Ping timeout: 250 seconds]
silasfox has joined #commonlisp
IAmRasputin has joined #commonlisp
IAmRasputin has quit [Ping timeout: 272 seconds]
amb007 has joined #commonlisp
selwyn has joined #commonlisp
lisp123 has joined #commonlisp
<shka> the most tragic history about the uncle bob
<beach> What?
<shka> is when he mentioned that nobody will be serious about the programming until software bug will cause a major aviation accident
<shka> but then Boeing Max happens
<beach> I think he is totally right.
<beach> Yes, that wasn't enough apparently.
<shka> and corporate don't care anyway :P
<beach> They will have to care if there is new legislation as he predicts.
<shka> yeah, it sounded ludicrous at first, but i actually think that this may be not be worst idea ever
VFR has quit [Ping timeout: 252 seconds]
lisp123 has quit [Ping timeout: 265 seconds]
<beach> I agree, but it would be a terrible idea presently. What will happen will depend a lot on the "experts" that are chosen to draft legislation. I won't be surprised if (say) free software is outlawed, and VSCode becomes mandatory, and stuff like that.
<beach> I mean, imagine they pick "experts" from (say) Oracle.
<shka> only java allowed
<shka> :P
<beach> Exactly.
<beach> That kind of stuff.
<Equill> Or Eiffel.
<Equill> Wait, you're right: Oracle won't promote that, will they? Ignore me.
<shka> Boeing also decided to move all of the software development to India
<beach> Wow.
<beach> Amazing.
<jcowan> Obviously Boeing has very good (and very expensive) e&o insurance, some of it paid for by taxpayers. I read once that aviation didn't become profitable (as opposed to pervasive) iuntil the 1960s or so
<beach> I am not worried about Boeing. I am worried about the future of software development.
<shka> jcowan: Boeing is not allowed to go out of business anyway
<shka> way to many military assets are connected to Boeing
<jcowan> Bear, Stearns wasn't either, and yet.
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
<jcowan> Software has been in crisis my whole life, almost.
<prxq_> the whole world is in crisis. It
<prxq_> 's the same pattern everywhere.
prxq_ is now known as prxq
selwyn has quit [Read error: Connection reset by peer]
tfb has joined #commonlisp
tfb has quit [Client Quit]
<jcowan> Hey, it's a fallen world.
<jcowan> Nevertheless, we do have quite a lot of nice things
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
domovod has joined #commonlisp
varjag has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
char has quit [Ping timeout: 250 seconds]
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
tfb has joined #commonlisp
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
selwyn has joined #commonlisp
yitzi has joined #commonlisp
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
selwyn has quit [Read error: Connection reset by peer]
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
sp41 has joined #commonlisp
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
amb007 has quit [Ping timeout: 272 seconds]
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
<pjb> well, airbus at least uses a Coq-validated C compiler: https://github.com/AbsInt/CompCert
<pjb> ⚠ not free software
<pjb> Perhaps one day we'll have a formal specification of CL, and a Coq validated CL compiler?
<pjb> (or ACL2 ?)
lisp123 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
lisp123 has quit [Ping timeout: 258 seconds]
tyson2 has quit [Remote host closed the connection]
Equill has quit [Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/]
lisp123 has joined #commonlisp
selwyn has joined #commonlisp
jans has joined #commonlisp
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
jans has quit [Remote host closed the connection]
silasfox has quit [Ping timeout: 250 seconds]
silasfox has joined #commonlisp
bhaible has quit [Remote host closed the connection]
bhaible has joined #commonlisp
yitzi has quit [Quit: Leaving]
lad has joined #commonlisp
cage has quit [Quit: rcirc on GNU Emacs 27.1]
waleee has joined #commonlisp
tyson2 has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
tyson2 has joined #commonlisp
selwyn has quit [Read error: Connection reset by peer]
tfeb has joined #commonlisp
tfeb has quit [Client Quit]
tyson2 has quit [Remote host closed the connection]
IAmRasputin has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
IAmRasputin has quit [Ping timeout: 268 seconds]
domovod has quit [Quit: WeeChat 3.2]
lisp123 has joined #commonlisp
tyson2 has joined #commonlisp
silasfox has quit [Ping timeout: 268 seconds]
lisp123 has quit [Ping timeout: 265 seconds]
silasfox has joined #commonlisp
unyu has joined #commonlisp
shka has quit [Quit: Konversation terminated!]
shka has joined #commonlisp
sp41 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
aleamb has quit [Quit: bye]
treflip has quit [Remote host closed the connection]
silasfox has quit [Ping timeout: 250 seconds]
silasfox has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
silasfox has quit [Ping timeout: 252 seconds]
lisp123 has quit [Ping timeout: 268 seconds]
shka has quit [Ping timeout: 265 seconds]
jeosol has quit [Quit: Ping timeout (120 seconds)]
<coat> I am trying to make a small wrapper that can push a cons to alist. (defun add-key-value (key value alist) (push (cons key value) alist)) (defparameter *a* nil) (add-key-value "foo" "bar" *a*). But *a* remains as NIL after I execute this.
<coat> How can I make the add-key-value function actually modify the alist?
<pjb> coat: if you really want to do that, you just use defsetf
<pjb> not defun
<pjb> coat: I guess you could also use define-modify-macro and acons.
<pjb> (define-modify-macro aconsf (key value) (lambda (alist key value) (acons key value alist))) (let ((alist '((a . 1) (b . 2)))) (aconsf alist 'c 3) alist) #| --> ((c . 3) (a . 1) (b . 2)) |#
<pjb> coat: unfortunately, a lot of CL functions don't have their parameters in the right order for define-modify-macro… So you need to swap them, eg. with that lambda.
<coat> pjb: Okay. Curious about another thing. Is creating a list and pushing cons to it not a popular way? Do people usually use acons instead?
<pjb> coat: note: it's bad to mutate state! Instead, use a local variable and acons!
<pjb> (let ((alist '((a . 1) (b . 2)))) (let ((alist (acons 'c 3 alist))) alist)) #| --> ((c . 3) (a . 1) (b . 2)) |#
<pjb> for alists, yes, acons is indicated.
kakuhen has joined #commonlisp
bilegeek has joined #commonlisp
elf_fortrez has joined #commonlisp
<jcowan> The whole point of alists is that they are persistent
selwyn has joined #commonlisp
elf_fortrez has quit [Quit: Client closed]
kevingal has joined #commonlisp
dsk has quit [Ping timeout: 244 seconds]
trocado has quit [Ping timeout: 272 seconds]
livoreno has quit [Read error: Connection reset by peer]
livoreno has joined #commonlisp
livoreno has quit [Read error: Connection reset by peer]
livoreno has joined #commonlisp
pve has quit [Quit: leaving]
lisp123 has joined #commonlisp
klltkr_ has joined #commonlisp
lisp123 has quit [Ping timeout: 272 seconds]
varjag has quit [Quit: ERC (IRC client for Emacs 28.0.50)]
frgo has quit [Remote host closed the connection]
frgo has joined #commonlisp
jeosol has joined #commonlisp
klltkr has joined #commonlisp
klltkr_ has quit [Ping timeout: 268 seconds]
Nilby has quit [Ping timeout: 265 seconds]
IAmRasputin has joined #commonlisp
IAmRasputin has quit [Ping timeout: 258 seconds]
andreyorst has quit [Ping timeout: 258 seconds]
andreyorst has joined #commonlisp
tfb has quit [Quit: died]
kevingal has quit [Remote host closed the connection]
[deleted] has joined #commonlisp
livoreno has quit [Ping timeout: 272 seconds]
klltkr has quit [Ping timeout: 272 seconds]
cjb has joined #commonlisp
tfb has joined #commonlisp
tfb has quit [Client Quit]
<jasom> doesn't cl:push leave the original list unchanged?
<jasom> I thought it only changed the slot that the list was stored in
<jasom> i.e. isn't this true? (let ((y x)) (push 'foo x) (eq (cdr x) y))
lotuseater has quit [Quit: ERC (IRC client for Emacs 27.2)]
[deleted] has quit [Read error: Connection reset by peer]
<aeth> the way lists go, a push is a cons, so how can it not do that? there is no list, only cons pairs
<moon-child> jasom: yes, otherwise it would be O(n) in the length of the referenced list
livoreno has joined #commonlisp
<aeth> pushes could only directly modify if the list data structure was actually one more pointer, a pointer to the first cons pair (or if it added to the end and was O(n))
<moon-child> it could also add to the beginning destructively, moving down the elements of each successive cons cell. Still O(n) though