phoe changed the topic of #lisp to: Common Lisp, the #1=(programmable . #1#) programming language | <http://cliki.net/> <https://irclog.tymoon.eu/freenode/%23lisp> <https://irclog.whitequark.org/lisp> <http://ccl.clozure.com/irc-logs/lisp/> | SBCL 1.4.16, CMUCL 21b, ECL 16.1.3, CCL 1.11.5, ABCL 1.5.0
themsay has quit [Remote host closed the connection]
themsay has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
libertyprime has joined #lisp
wxie has joined #lisp
playful-owl has quit [Quit: leaving]
<phoe> pjb: yep, I found it in serapeum as well. It's a one-liner using LOOP.
robdog has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
jack_rabbit_ has joined #lisp
robdog has joined #lisp
varjag has quit [Ping timeout: 250 seconds]
robdog has quit [Ping timeout: 250 seconds]
Lord_of_Life_ has joined #lisp
elderK has joined #lisp
robdog has joined #lisp
Lord_of_Life has quit [Ping timeout: 245 seconds]
Lord_of_Life_ is now known as Lord_of_Life
robdog has quit [Ping timeout: 250 seconds]
ym555 has quit [Ping timeout: 250 seconds]
robdog has joined #lisp
oystewh has joined #lisp
robdog_ has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
Oladon has quit [Quit: Leaving.]
tharugrim has quit [Quit: WeeChat 2.4]
robdog_ has quit [Ping timeout: 250 seconds]
jack_rabbit_ has quit [Ping timeout: 250 seconds]
pankajgodbole has joined #lisp
karlosz has joined #lisp
robdog has joined #lisp
lumm has quit [Remote host closed the connection]
robdog has quit [Ping timeout: 250 seconds]
ciaranb has quit [Ping timeout: 246 seconds]
Inline has joined #lisp
robdog has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
lucasb has quit [Quit: Connection closed for inactivity]
makomo has quit [Ping timeout: 250 seconds]
Oladon has joined #lisp
robdog has joined #lisp
libertyprime has quit [Ping timeout: 250 seconds]
Essadon has quit [Quit: Qutting]
vibs29 has quit [Read error: Connection reset by peer]
robdog has quit [Ping timeout: 250 seconds]
vibs29 has joined #lisp
jmercouris has joined #lisp
<jmercouris> I have (flet ((func (x) (print x))) (mapcar func listz)) and it complains that func is unused
<jmercouris> "deleting unused function" when compiling in sbcl
<jmercouris> must I use #'?
<jmercouris> why is it sometimes to only quote a symbol rather than using the explicit function notation
<jmercouris> is it another example of a so called "forgiving" function, like string-downcase?
robdog has joined #lisp
<didi> jmercouris: Others can explain it in more details, but FLET dines local named functions. By calling (mapcar 'func listz), you're passing a function designator, not the function.
<didi> s/dines/defines
<didi> "The names of functions defined by flet are in the lexical environment; they retain their local definitions only within the body of flet."
<jmercouris> so (quote func) is only a symbol that designates a ffunction rather than #' which somehow explicitly notes a function
<jmercouris> is that what you are saying?
<didi> jmercouris: It is.
<jmercouris> I wonder why some functions accept function designators sometimes
<jmercouris> or rather symbols that are pointing to functions
<jmercouris> which is I guess what we mean when we say "function designators"
robdog has quit [Ping timeout: 250 seconds]
<White_Flame> (eq (function +) (symbol-function '+)) => T
PuercoPope has joined #lisp
<jmercouris> I see
<White_Flame> since FUNCALL and APPLY accept function designators, anything that falls through to that implicitly supports them
<jmercouris> yes
<White_Flame> in your original question, mapcar can't see the lexical binding of FUNC, and nothing you pass to it links to it
<didi> jmercouris: I learned to use #' after a COMPLEMENT failed with a symbol deep inside my program.
<White_Flame> also #' is probably a bit faster
<jmercouris> why can it not see the lexical binding?
<jmercouris> is flet a macro?
<didi> jmercouris: Lexical binding it about space.
<jmercouris> didi: can you please rephrase
<didi> jmercouris: CLtL2 has a nice chapter about it.
<didi> jmercouris: Read chapter 3. Scope and Extent. It will do a better job than I will ever be able to.
<jmercouris> CLtL2 ? common lisp the language 2?
<didi> jmercouris: Indeed.
<jmercouris> ok, will do
<jmercouris> same site I was able to get gentle introduction to symbolic computation
hyero has quit [Remote host closed the connection]
<jmercouris> that was a good read
<jmercouris> though I did not enjoy the recursion section of the book
<jmercouris> no matter how much I practice recursion, I just don't enjoy it
<didi> jmercouris: It grows on you. Specially while using lisp.
benjamin-l has joined #lisp
<jmercouris> maybe in a few years
<jmercouris> but I've been a computer scientist for about 10 years now
<jmercouris> and I still don't enjoy it
<jmercouris> only have been doing lisp for about 2 years though
<didi> jmercouris: That's fine. I still bet you will enjoy it.
karlosz has quit [Quit: karlosz]
<White_Flame> jmercouris: did you also get an error about FUNC being unbound when you're passing it into mapcar?
<jmercouris> no, it was quote
<White_Flame> ah, ok
<jmercouris> if I remove the quote, of course
<White_Flame> so you're just passing a symbol. Mapcar can't see anything about that symbol besides its toplevel symbol-value, symbol-function etc
<White_Flame> your flet is only lexically visible within the flet scope
<jmercouris> write, and since it is lexically bound, and not toplevel, it doesn't work
<jmercouris> damnit you typed faster than me
<White_Flame> the call to mapcar is outside taht
<jmercouris> yes, I get it now
<jmercouris> thanks for clarification and confirmation though :)
<jmercouris> as an aside, White_Flame , what is your typing speed?
<White_Flame> this keyboard I'm on now sucks, but I've hit 200wpm
<jmercouris> I see, so you are a little bit faster than me
<jmercouris> my peak has been around 180, and I can average 100-120 for sustained periods of time
<jmercouris> the problem usually becomes thinking that fast :D
<didi> "problem"...
<didi> :-P
robdog has joined #lisp
robdog_ has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
<pjb> (let ((var-bound-to-fun (lambda (x) (print x)))) (mapcar var-bound-to-fun '(1 2 3)))
<pjb> (flet ((fun-fbound-to-fun (x) (print x))) (mapcar (function fun-fbound-to-fun) '(1 2 3)))
<jmercouris> Its on my reading list, probably a bit too high level for me at a cursory glance
<jmercouris> but I'll take a look when I have a moment
<pjb> let <-> flet bound <-> fbound var <-> (function f) (funcall var) <-> (f)
<pjb> jmercouris: you should read it now.
<spacedbat> the price of a lisp-2
<pjb> Actually, you should have read it yesterday, since today you're asking about it!
robdog_ has quit [Ping timeout: 250 seconds]
ebrasca has quit [Remote host closed the connection]
<jmercouris> pjb: I would, but I have some deadlines, its also late o'clock
robdog has joined #lisp
<PuercoPope> There is an advantage to using the symbol instead of the function itself. Because the symbol is looked up when the code is run if you redefine the function you'll get the new function instead of keeping a reference to the old function object until you recompile the call sites as well
<didi> spacedbat: More like lisp-7 /me channels PAIP
<jmercouris> pjb: I thought you woke up early, what time do you sleep?
<pjb> random, basically.
<didi> PuercoPop: I miss that.
<jmercouris> PuercoPop: Yes, that's why I usually prefer quote to handle redefinitions
robdog has quit [Ping timeout: 250 seconds]
karlosz has joined #lisp
MightyJoe has quit [Ping timeout: 255 seconds]
cyraxjoe has joined #lisp
themsay has quit [Read error: Connection reset by peer]
themsay has joined #lisp
themsay has quit [Read error: Connection reset by peer]
themsay has joined #lisp
robdog has joined #lisp
orivej has quit [Ping timeout: 246 seconds]
robdog has quit [Ping timeout: 250 seconds]
robdog has joined #lisp
keep_learning_M has quit [Ping timeout: 245 seconds]
zotan has quit [Ping timeout: 257 seconds]
zotan has joined #lisp
nicdev has quit [Quit: ERC (IRC client for Emacs 26.1)]
nicdev has joined #lisp
keep_learning_M has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
robdog has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
keep_learning_M has quit [Ping timeout: 246 seconds]
jmercouris has quit [Remote host closed the connection]
keep_learning_M has joined #lisp
robdog has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
FreeBirdLjj has joined #lisp
FreeBirdLjj has quit [Read error: Connection reset by peer]
FreeBirdLjj has joined #lisp
caltelt_ has joined #lisp
FreeBirdLjj has quit [Ping timeout: 246 seconds]
mooshmoosh has quit [Ping timeout: 272 seconds]
_whitelogger has joined #lisp
smasta has quit [Ping timeout: 245 seconds]
vibs29 has joined #lisp
smasta has joined #lisp
smasta has quit [Ping timeout: 272 seconds]
<beach> Good morning everyone!
<gilberth> didi: Scheme is over there -->
<didi> gilberth: Scheme doesn't have this issue? http://www.nhplace.com/kent/Papers/Technical-Issues.html says it can happen with Lisp_1 too.
<gilberth> didi: Don't ask me. I just was kidding, because Schemers think our macro system is dirty.
<didi> Ah...
<didi> I see.
<gilberth> didi: Perhaps it can, I tried to be funny in a way. Though I don't remember much Scheme. I love my dozen namespaces.
* didi hugs lisp
Oladon has quit [Quit: Leaving.]
<gilberth> didi: Any luck with your compiler macro?
impulse has joined #lisp
<didi> gilberth: Nope. I tried reading CLtL2, but this stuff is hard. I guess I'll stay with (defmacro mfn (x) (fn ,x)) for now.
keep_learning_M has quit [Ping timeout: 255 seconds]
<gilberth> didi: OK, if that works for you, the better. But dig the different evaluation times when you have time for that.
<didi> gilberth: Thanks, I will.
<gilberth> didi: And nobody ever claimed that Lisp is easy. :)
<didi> gilberth: They said it had no syntax!
<gilberth> didi: But it is a lot of fun once you master it.
keep_learning_M has joined #lisp
<didi> *nod*
<gilberth> didi: Well, for the proper definition of syntax.
<didi> gilberth: Always the small font... ;-)
<gilberth> didi: Xach said I am olde, so I use a larger font these days.
MightyJoe has joined #lisp
cyraxjoe has quit [Ping timeout: 246 seconds]
<PuercoPope> is there any reason to prefer ash vs dpb/ldb when 'buidling' integers from octets? Most code I've found in the open uses ash but I'm inclined to think it is more a more a consquence of familiarity with C
<gilberth> I prefer DPB and LDB.
<gilberth> And here is why: The exact "subsequence" of bits named the byte is explicitly mentioned in the involving BYTE.
robdog has joined #lisp
torbo has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
smasta has joined #lisp
smasta has quit [Ping timeout: 255 seconds]
<PuercoPope> its also more 'clear'. "I want to put this bytes here" instead of add this number and move them to the right X times
<PuercoPope> I was surprised to learn that ldb only works on integeres. Is there a reason why it couldn't work on floats?
karlosz has quit [Quit: karlosz]
<gilberth> I agree. And size and position of the byte is in one place.
<gilberth> You also could do, say, (DEFCONSTANT +OPCODE-BYTE+ (BYTE 4 28)) and later just (LDB +OPCODE-BYTE+ X)
<gilberth> With ASH and LOGAND, you would need +OPCODE-SHIFT+ and +OPCODE-MASK+.
<gilberth> All IMHO.
<gilberth> PuercoPope: Would (DPB 1.0 (BYTE 1 1000) 1.0) work?
dddddd has quit [Remote host closed the connection]
<gilberth> To answer the original question: Yes, I believe DPB/LDB is "cleaner", but people are just used to ASH/LOGAND/LOGIOR because of C idioms.
caltelt_ has quit [Ping timeout: 250 seconds]
<PuercoPope> gilberth: no, because the spec says the first and last argument must be integers
<PuercoPope> is there a different encoding to floats than ieee-754?
<gilberth> You were asking, why it wouldn't work on floats. So imagine it would, what would happen?
<gilberth> There were quite a lot different encodings.
<gilberth> ANSI CL specifically does not stick to any particular float encoding. Even decimal floats are possible. See INTEGER-DECODE-FLOAT or what ever that is called.
<gilberth> IIRC the 8087 also has some 80-bit floating point format.
* gilberth is olde.
<PuercoPope> I as unware there were different encoding to floats, in that case it doesn't make sense for ldb to work on floats.
<gilberth> Did you imagine for LDB and DPB to work on the underlying bit pattern? Instead of the mathematical value?
Aruseus has quit [Remote host closed the connection]
<gilberth> As in: I have a double --- that are 64 bits --- here and there is the exponent and there is the sign?
polezaivsani has quit [Remote host closed the connection]
<gilberth> And then the IEEE format is nuts anyway, I hope we replace it by something more reasonable.
notzmv has quit [Ping timeout: 245 seconds]
didi has left #lisp ["O bella ciao bella ciao bella ciao, ciao, ciao."]
<gilberth> But then the interface of DECODE-FLOAT and friends is pretty nice.
fouric has joined #lisp
<PuercoPope> gilberth: yeah, like single-float had only one representation. But if it is like chars, it is a good idea to not leak the concrete encoding into the rest of the language
smasta has joined #lisp
<gilberth> PuercoPope: Correct. That way to extend the character datatype to 29-bit code points didn't hurt.
<gilberth> It was a pain in the late 90'ies though, as most Lisp still where 8-bit there.
<gilberth> So, when we make contact to aliens, which have their own 40-bit character set, we could easily extend the character data type with no damage done. :-)
smasta has quit [Ping timeout: 272 seconds]
<gilberth> Actually I love that. We run code, which is 30 years old or older. And it'll still run in 30 years.
<gilberth> C is not like that. Try to compile system 7 code --- no luck.
<PuercoPope> One problem with old code is loading it. Not all old code used mkdefsystem which translates more or less to ASDF. For example loading op5 in SBCL is not straighforward. But I agree its nice for code not to bitrot
orivej has joined #lisp
<gilberth> Well, that is loading "only". Look at CXML for example. I started to write that some 20 years ago and people still use that. Though I have no idea who maintains it right now.
<PuercoPope> There are two versions of it right now
<gilberth> Two?!
<PuercoPope> the Sharplispers one and the fork FXML
* gilberth is puzzled.
<gilberth> Why?
<PuercoPope> by Ruricolist, which was used in a comercial product until recently
<PuercoPope> because it was unmantained so the author didn't know where to submit patches to
<gilberth> I see.
<gilberth> It still has this RUNE and ROD abstraction, which should go away.
impulse has quit [Ping timeout: 255 seconds]
<gilberth> There is still older code out there. I still use lalr.lisp from 1988, initially written by Mark Johnson.
<PuercoPope> CLX is pretty old, but sadly the VCS history is 'lost' prioer to the early 2000s
torbo has quit [Remote host closed the connection]
<gilberth> Point is: I love that Common Lisp is machine independent. In C an "int" is something different everywhere.
<gilberth> That is a pity. I used to hack CLX.
<gilberth> I am also the culprit behind: http://bauhh.de/clxman/
<gilberth> That once was a straight 72 hour session to convert from some strange typesetting system to SGML and generating HTML.
<PuercoPope> The current one is generated from texinfo https://sharplispers.github.io/clx/
<gilberth> I know. And that is a good thing.
impulse has joined #lisp
<gilberth> People were unhappy with SGML, which I can understand.
<PuercoPope> I haven't bothered to learn texinfo and now that you can generate info manuals from Org mode I don't think I'll ever will. Its a pitty because modern documentation tools pays little attention to things like indexes
<gilberth> Do we need indexes, when we have a proper search function?
orivej has quit [Ping timeout: 246 seconds]
<PuercoPope> It helps w/ autocomplete at the very least. But having indexes is a prerequiste to having proper search
<PuercoPope> (I didn't mean index section, just indexes as pre-processing the data)
<gilberth> What I find more important is the term/concept idea. We have that in the CLIM spec. It says, say, "The argument x must be a foo."
<gilberth> Then "foo" is a term and it should link to a definition, what a foo is.
<gilberth> The latter is the concept.
rippa has joined #lisp
vlatkoB has joined #lisp
vibs29 has quit [Ping timeout: 246 seconds]
nalkri has joined #lisp
vibs29 has joined #lisp
<pjb> /whoami
smasta has joined #lisp
smasta has quit [Ping timeout: 250 seconds]
PuercoPope has quit [Remote host closed the connection]
smasta has joined #lisp
robdog has joined #lisp
makomo has joined #lisp
smasta has quit [Ping timeout: 250 seconds]
vibs29 has quit [Ping timeout: 250 seconds]
vibs29 has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
varjag has joined #lisp
varjag has quit [Ping timeout: 250 seconds]
Nomenclatura has joined #lisp
troydm has joined #lisp
d4ryus has quit [Quit: WeeChat 2.4]
smasta has joined #lisp
d4ryus has joined #lisp
pankajgodbole has quit [Ping timeout: 250 seconds]
smasta has quit [Ping timeout: 250 seconds]
vlatkoB_ has joined #lisp
dale has quit [Quit: dale]
vlatkoB has quit [Ping timeout: 255 seconds]
gigetoo has quit [Ping timeout: 245 seconds]
random-nick has joined #lisp
akssri has joined #lisp
akssri is now known as akssri_
akssri_ is now known as akssri
nullheroes has quit [Quit: WeeChat 2.3]
bendersteed has joined #lisp
SaganMan has joined #lisp
gigetoo has joined #lisp
ym555 has joined #lisp
smasta has joined #lisp
rozenglass has joined #lisp
smasta has quit [Ping timeout: 250 seconds]
robdog has joined #lisp
nalkri has quit [Ping timeout: 246 seconds]
robdog has quit [Ping timeout: 250 seconds]
rumbler31 has joined #lisp
steiner has joined #lisp
steiner has left #lisp [#lisp]
rumbler31 has quit [Ping timeout: 245 seconds]
feynhat has joined #lisp
<feynhat> hello
<feynhat> I am trying to use this library called "kenzo", which I have installed via quicklisp.
<feynhat> How do I use its member functions?
<feynhat> I've read a few SO posts, and have tried (use-package :kenzo).
<feynhat> But I get this: "The name :KENZO does not designate any package."
<phoe> feynhat: (ql:quickload :quicklisp)
<phoe> I mean uhh
<phoe> feynhat: (ql:quickload :kenzo)
<feynhat> Yes, I have done that.
<phoe> then let's figure out what packages kenzo exports
<White_Flame> in the SLIME repl, kenzo:<TAB> to see what autocompletes is a good starting point to read
<phoe> White_Flame: psych, there's no package named KENZO it seems
<White_Flame> okay, then cat:<TAB> :-P
<phoe> yes, (in-package :cat)
<White_Flame> there's also a doc/ directory, as well as exmplaes & tests
<feynhat> White_Flame, phoe Thanks a lot!
<feynhat> cat worked
<feynhat> phoe, was it really necessary though? I am sure people who are familiar with lisp would have figured this out quickly.
<feynhat> *or even those who aren't.
<phoe> feynhat: no idea if it's necessary, but perhaps it's useful.
lumm has joined #lisp
themsay has quit [Read error: Connection reset by peer]
themsay has joined #lisp
smasta has joined #lisp
smasta has quit [Ping timeout: 250 seconds]
akssri has quit [Ping timeout: 245 seconds]
asdf_asdf_asdf has joined #lisp
<asdf_asdf_asdf> Hi. Why (setq x 0) throw warning?
<asdf_asdf_asdf> undefined variable: X
<MichaelRaskin> The expectation is that either you defvar/defparameter the variable in advance, or create a local binding with let
<phoe> asdf_asdf_asdf: you should define variables before you use them
<phoe> that is, either lexical variables via LET and company
<phoe> or global dynamic variables via DEFVAR or DEFPARAMETER
feynhat has quit [Remote host closed the connection]
polezaivsani has joined #lisp
<asdf_asdf_asdf> (defun x () (defvar *a* 0) (+ *a* 1)) => warning
<no-defun-allowed> You need to defvar at the top level, ie outside any functions.
nalkri has joined #lisp
<phoe> How do I check if two values are both true or both false?
<phoe> That would be a XNOR operation.
<jackdaniel> how about (eq (not a) (not b)) ?
<jackdaniel> phoe: ↑
<nalkri> Can't is just be (not (xor a b))?
<nalkri> Only, like, assume I used English
<jackdaniel> nalkri: is there xor operation in cl package?
<nalkri> Yes I think so
<nalkri> Sorry, I'm just barging in without context though I'll be shush
<jackdaniel> I'm only aware about numerical operations (logxor and bit-xor)
<nalkri> I shouldn't have said anything, just ignore me :)
kushal has quit [Remote host closed the connection]
kushal has joined #lisp
wxie has quit [Remote host closed the connection]
wxie has joined #lisp
<phoe> jackdaniel: that's good, thanks
<phoe> jackdaniel: alexandria:xor
<asdf_asdf_asdf> Why variable global can't be inside function, only outside function?
<jackdaniel> phoe: I was asking about cl package. I'm sure there is some serapeum:xnor too
<phoe> jackdaniel: there's none
<jackdaniel> but if we assume that we ask about "potential" function, then question is meaningless
<jackdaniel> because you may always just put the name of said function and pass arguments
<jackdaniel> asdf_asdf_asdf: defvar may be put as part of function body, but it is rarely what you want
<jackdaniel> because such defvar will take effect only *after* executing said function
<jackdaniel> so if you use this variable elsewhere, then compilation will either fail or warn you about undefined symbol usage
<asdf_asdf_asdf> jackdaniel, so I must have variable outside function, to works?
<jackdaniel> I think that you would benefit from reading some introductory material for programming (and if you have some experience, reading practical common lisp obok)
<jackdaniel> minion: please tell asdf_asdf_asdf about pcl
<minion> asdf_asdf_asdf: please see pcl: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
<phoe> asdf_asdf_asdf: (defun x () (let ((x 0)) (+ x 1)))
smasta has joined #lisp
smasta has quit [Ping timeout: 250 seconds]
nowhere_man has quit [Ping timeout: 258 seconds]
p9fn has quit [Ping timeout: 264 seconds]
<Grue`> minion: memo for didi: you can avoid that with (funcall 'square ,y) because then you're only calling standard functions which cannot be redefined with flet, and 'square takes the global definition of square
<minion> Remembered. I'll tell didi when he/she/it next speaks.
Inline has quit [Quit: Leaving]
asdf_asdf_asdf has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
bendersteed has quit [Ping timeout: 245 seconds]
bendersteed has joined #lisp
Inline has joined #lisp
MightyJoe has quit [Ping timeout: 250 seconds]
cyraxjoe has joined #lisp
angavrilov has joined #lisp
asdf_asdf_asdf has joined #lisp
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 246 seconds]
gxt has joined #lisp
ym555 has quit [Ping timeout: 250 seconds]
smasta has joined #lisp
robdog has joined #lisp
smasta has quit [Ping timeout: 246 seconds]
smasta has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
dddddd has joined #lisp
smasta has quit [Ping timeout: 244 seconds]
Lord_of_Life_ has joined #lisp
Lord_of_Life has quit [Ping timeout: 250 seconds]
Lord_of_Life_ is now known as Lord_of_Life
smasta has joined #lisp
smasta has quit [Ping timeout: 245 seconds]
wigust- has joined #lisp
wigust has quit [Ping timeout: 246 seconds]
<dtw> Is there a package for "unquoting" C language strings (backslash escaped things)?
andrei-n has joined #lisp
<dlowe> I can't think of one off the top of my head.
ebrasca has joined #lisp
asdf_asdf_asdf has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
SaganMan has quit [Quit: WeeChat 1.6]
CrazyEddy has quit [Ping timeout: 268 seconds]
lucasb has joined #lisp
elderK has quit [Quit: Connection closed for inactivity]
rumbler31 has joined #lisp
smasta has joined #lisp
rumbler31 has quit [Ping timeout: 246 seconds]
smasta has quit [Ping timeout: 246 seconds]
vms14 has joined #lisp
polezaivsani has quit [Remote host closed the connection]
polezaivsani has joined #lisp
bendersteed has quit [Remote host closed the connection]
mrcom has quit [Ping timeout: 272 seconds]
robdog has joined #lisp
Arcaelyx has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
kdas_ has joined #lisp
kushal has quit [Ping timeout: 256 seconds]
wxie has quit [Ping timeout: 250 seconds]
robdog has joined #lisp
shka_ has joined #lisp
DrPete has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
robdog has joined #lisp
cyraxjoe has quit [Ping timeout: 250 seconds]
MightyJoe has joined #lisp
kdas_ is now known as kushal
robdog has quit [Ping timeout: 250 seconds]
MightyJoe has quit [Ping timeout: 244 seconds]
robdog has joined #lisp
cyraxjoe has joined #lisp
DrPete has quit [Ping timeout: 250 seconds]
elazul has joined #lisp
DrPete has joined #lisp
orivej has joined #lisp
robdog_ has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
MightyJoe has joined #lisp
cyraxjoe has quit [Ping timeout: 250 seconds]
klltkr has joined #lisp
<dtw> dlowe: Here is my own quick hack that may need further polishing and thinking (function UNESCAPE-C-STRING): http://paste.debian.net/1074448/
robdog has joined #lisp
robdog_ has quit [Ping timeout: 250 seconds]
<vms14> guys I sometimes see js has some lispy stuff
<vms14> and that js was influenced by lisp
<vms14> there is a way to do something near to lisp macros with js?
<vms14> it has the eval function, but idk if there is a way to do `code,data tricks
ym555 has joined #lisp
robdog_ has joined #lisp
<beach> If you program in Common Lisp instead, you don't have to think about it.
Nomenclatura has quit [Quit: q]
mrcom has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
robdog_ has quit [Ping timeout: 250 seconds]
<vms14> I hope I will program in common lisp someday
asdf_asdf_asdf has joined #lisp
<beach> What's holding you back?
<makomo> vms14: what you linked is an implementation of lisp (scheme) in javascript (not an actual feature of js)
<vms14> also I want to check if it's true that when you learn Lisp, you'll change as a programmer
<vms14> I have two books recommended to read that could make me a nice programmer
<Inline> the jeckl and hyde lisper ?
<Inline> lol
<vms14> the PAIP, and the pragmatic programmer book
<vms14> makomo,sad, but it's something near to macros, it seems
<beach> vms14: I think your time will be better spent aiming to program sooner in Common Lisp.
<vms14> beach, time and myself
<vms14> right, I want to start with hunchentoot soon to use it as a server
<vms14> and also check parenscript and alike
<vms14> but I need to learn basics first
<vms14> Just need to focus on PAIP and I will, but I'm learning webdevelopment because I'm on a course
<ebrasca> How is Second-Climacs going?
<pjb> dtw: there are several implementations of a C string reader macro.
<makomo> vms14: well, it's an implementation of the backquote mechanism but all of it is at the level of the implemented language (scheme), not js
<vms14> yeah the best solution to have macros in js should use parenscript
<vms14> but parenscript needs serverside stuff?
<phoe> no
<phoe> parenscript compiles to JS that is run in the browser
<makomo> vms14: parenscript is "just" a cl to js compiler
<vms14> it can transpile to a js file then?
<makomo> it's a cl package/program that takes common lisp code as input and compiles it into js
<phoe> yes
<phoe> it takes a subset of CL and compiles it to JS
<pjb> dtw: see the annotation, actually http://paste.lisp.org/display/137262#1
<vms14> and it's the best library available for that job?
<phoe> t
<makomo> probably
<vms14> xD
<dtw> pjb: Thank you. Those don't _seem_ to handle \\u and \\U codes but are most likely better than my quick hack.
<vms14> tnx for the help, see you
vms14 has quit [Quit: Leaving]
<pjb> dtw: see the date, c17 didn't exist yet.
<pjb> (if \u and \U are c17…)
robdog has joined #lisp
<pjb> dtw: are you a programmer?
Aruseus has joined #lisp
<dtw> pjb: hobbyist programmer :)
<pjb> good. Have fun adding \u and \U to it! ;-)
Ukari has quit [Remote host closed the connection]
ebrasca has quit [Remote host closed the connection]
Ukari has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
<makomo> pjb: as i learned myself the other day, you should probably handle the case of *READ-SUPPRESS* being bound to T within your reader macros
<makomo> pjb: (let ((*read-suppress* t)) (read-from-string "?\\x2"))
<makomo> :-)
<makomo> also, i think you should pass T for RECURSIVE-P when calling READ
ebrasca has joined #lisp
<pjb> Yes.
<asdf_asdf_asdf> (defun push2 (item1 place1) (setf place1 (cons item1 place1))) => PUSH2
<asdf_asdf_asdf> Why it not works?
<beach> asdf_asdf_asdf: It works as advertised.
<beach> It modifies the local variable place1.
<makomo> asdf_asdf_asdf: PLACE1 is local to the function
<beach> Then the function exits and the modification is gone.
<pjb> Because you're mutating the variable place1, which has nothing in common with the variable x in (let ((x '())) (push2 1 x) x)
<beach> asdf_asdf_asdf: Do you know any other language, like C?
vibs29 has quit [Ping timeout: 246 seconds]
<beach> asdf_asdf_asdf: void add2 (int item, int variable) {variable += item;}
<beach> asdf_asdf_asdf: Do you understand that C code? (I hope the syntax is right).
robdog has joined #lisp
<asdf_asdf_asdf> beach, thanks. Really is it local variable not global. Already works.
vibs29 has joined #lisp
<beach> asdf_asdf_asdf: So if you understand that C code (you didn't say either way), then you know that add2(234, x) does not alter x.
<asdf_asdf_asdf> I know, thanks. Variable must be global, to change value.
<beach> asdf_asdf_asdf: Similarly, in Common Lisp, if you call push2 with a variable as a second argument, that variable is not altered by the call to push2.
<beach> asdf_asdf_asdf: Yes, but that is not a good way to program.
<beach> asdf_asdf_asdf: Instead, use the values that functions return.
<Aruseus> beach, but setf evaluates to the new value of place1, right?
<pjb> Instead, use: (defun push3 (item1 place1) (cons item1 place1)) (let ((x '())) (setf x (push3 42 x)) x)
<pjb> Aruseus: no, it evaluates the place, not the value of the place.
<beach> Aruseus: I don't understand.
notzmv has joined #lisp
<makomo> pjb: Aruseus said "to"
<makomo> Aruseus: it does, but that doesn't make any difference
<beach> Aruseus: Perhaps you are talking about the SETF form, as opposed to SETF.
<pjb> (setf (aref (gethash :v *h*) (round (* 10 (sin theta)))) 42) this evalautes (gethash :v *h*) and (round (* 10 (sin theta))), but not (aref (gethash :v *h*) (round (* 10 (sin theta)))).
<makomo> most likely :-)
<pjb> Oh, right.
<Aruseus> sorry, I'm new to lisp. I just thought (setf x 3) for example evaluates to 3
<pjb> Aruseus: actually to the new value of the last place.
<pjb> (setf x 3 y 4) -> 4
<beach> Aruseus: It does, and that is called the "SETF form".
<beach> Aruseus: But SETF itself does not evaluate to anything. It is not in a position to be evaluated.
nullheroes has joined #lisp
<beach> Aruseus: So when you said "but setf evaluates to..." I could not understand.
<Aruseus> oh ok, I get it
domovod has joined #lisp
<Aruseus> beach, thank you
<beach> Sure.
<beach> Common Lisp terminology is not very "fault tolerant", so it is important to use precise terminology.
<Aruseus> pjb, would (setf x 3 y) crash?
robdog_ has joined #lisp
<beach> It is invalid syntax.
smasta has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
Essadon has joined #lisp
varjag has joined #lisp
<Aruseus> interesting, apparently you can have zero pairs, so (setf) is valid
<beach> Indeed.
<pjb> #+ccl (setf) #| --> nil |# Shouldn't be that no values instead?
<pjb> The all return nil…
<pjb> They
robdog has joined #lisp
smasta has quit [Ping timeout: 250 seconds]
<_death> results---the multiple values[2] returned by the storing form for the last place, or nil if there are no pairs.
smasta has joined #lisp
<pjb> oh, good!
robdog_ has quit [Ping timeout: 250 seconds]
robdog has quit [Ping timeout: 250 seconds]
smasta has quit [Ping timeout: 250 seconds]
robdog has joined #lisp
pankajgodbole has joined #lisp
warweasle has joined #lisp
robdog_ has joined #lisp
robdog has quit [Ping timeout: 268 seconds]
bendersteed has joined #lisp
pierpal has quit [Quit: Poof]
pierpal has joined #lisp
robdog_ has quit [Ping timeout: 250 seconds]
Ukari has quit [Ping timeout: 250 seconds]
<asdf_asdf_asdf> How change global variable inside function? (defvar *x* 5) (defun aaa (a) (setf a 6)) I want: *x* => 6. How it do? Thanks.
<beach> asdf_asdf_asdf: You can't with a function.
<beach> asdf_asdf_asdf: You ask many questions, but you don't like to answer the ones that you are asked do you?
<pjb> (defun set-global-binding (var value) (set var value))
<pjb> err, sorry, s/set-global-binding/set-dynamic-binding/
<beach> asdf_asdf_asdf: I asked whether you know C, but you did not answer.
<asdf_asdf_asdf> beach, only a little I know C. Very small.
hiroaki has joined #lisp
<pjb> asdf_asdf_asdf: but actually, have a look at: https://www.informatimago.com/articles/usenet.html#C-like-pointers-in-Lisp
<pjb> since SET only works on special variables (dynamic bindings).
elazul has quit [Ping timeout: 246 seconds]
<beach> asdf_asdf_asdf: OK, so if you do int x = 5; then void set_global_binding (int a) {a = 6;}
<beach> What do you get?
nullheroes has quit [Quit: WeeChat 2.3]
<beach> ... if you call set_global_binding(x)
<beach> asdf_asdf_asdf: Like C and most other languages, Common Lisp uses "call by value", meaning that argument expressions are evaluated before the function is applied to those values.
smasta has joined #lisp
agspathis has joined #lisp
agspathis has quit [Client Quit]
agspathis has joined #lisp
robdog has joined #lisp
smasta has quit [Ping timeout: 250 seconds]
<asdf_asdf_asdf> Not works: ... (set var value).
<beach> asdf_asdf_asdf: pjb's examples are often too sophisticated for someone at your level.
tharugrim has joined #lisp
<asdf_asdf_asdf> (defun aaa (&treat_as_original a) (setf a 100)) => AAA. (defvar *x* 0) (aaa *x*) => 100 *x* => 100.
Ukari has joined #lisp
Josh_2 has quit [Read error: Connection reset by peer]
robdog has quit [Ping timeout: 268 seconds]
warweasle has quit [Quit: spank me]
<beach> asdf_asdf_asdf: How about just accepting that it is not possible.
<beach> asdf_asdf_asdf: Even if it were possible, you don't want to program that way.
<beach> asdf_asdf_asdf: Common Lisp has something called "macros" that can be used exceptionally for situations like that.
<beach> asdf_asdf_asdf: For example, SETF is such a macro. It is not a function.
<beach> asdf_asdf_asdf: But this is way too early in your studies to worry about.
<phoe> asdf_asdf_asdf: (defun aaa () (setf *x* 6))
<phoe> this changes the global value of *x*
<beach> asdf_asdf_asdf: As a first-order approximation, it is generally a bad idea to have variables in the caller be modified by a function call.
<asdf_asdf_asdf> phoe, I want as argument function, that changes global variable.
<beach> asdf_asdf_asdf: IT IS NOT POSSIBLE!
<beach> asdf_asdf_asdf: Read up on "call by value" please.
<asdf_asdf_asdf> I want change value variable global using function.
<nirved> asdf_asdf_asdf: (defmacro aaa (a) `(setf ,a 100))
<beach> asdf_asdf_asdf: IT IS NOT POSSIBLE! Read that paragraph in the Wikipedia page.
<beach> asdf_asdf_asdf: What part of "IT IS NOT POSSIBLE" do you not understand?
<beach> I guess it depends on what "IS" is.
<beach> asdf_asdf_asdf: Maybe there is a Wikipedia page for that in your native language.
sjl_ has quit [Ping timeout: 245 seconds]
<beach> asdf_asdf_asdf: If you tell me your native language, I will check and see if there is an equivalent page.
nullheroes has joined #lisp
<nirved> beach: if the ip address in the log is correct, then it's polish
<beach> Ah, OK.
<beach> No luck. :(
<asdf_asdf_asdf> beach, I understand probably. Calling by value we do copy variable.
<beach> NO, THE VALUE IS COPIED INTO A LOCAL VARIABLE.
<beach> The variable is not copied.
<beach> There is not even the concept of copying a variable.
<phoe> asdf_asdf_asdf: are you Polish?
<asdf_asdf_asdf> phoe, I don't tell you.
<beach> asdf_asdf_asdf: Why not, there are plenty of smart Polish people here that could help you in your native language.
<beach> asdf_asdf_asdf: ... and phoe is one of them. He is offering to help you.
<phoe> asdf_asdf_asdf: we could get the language barrier out of the way if you were.
<phoe> tak na przykład mówiąc ci o #lisp-pl. (;
jack_rabbit_ has joined #lisp
d4ryus has quit [Quit: WeeChat 2.4]
hiroaki has quit [Ping timeout: 245 seconds]
vibs29 has quit [Ping timeout: 245 seconds]
<pjb> asdf_asdf_asdf: you need to quote the argument, since SET works on symbols. Didn't you read clhs set?
vibs29 has joined #lisp
<pjb> (defun set-dynamic-binding (var val) (set var val)) (defvar *x* 0) (set-dynamic-binding '*x* 42) *x* #| --> 42 |#
<pjb> asdf_asdf_asdf: in C, you use & to pass the address of the place you want to mutate.
<pjb> asdf_asdf_asdf: so it is possible. But you should not do that! First, you should not use global variables!
d4ryus has joined #lisp
<pjb> Then since arguments are passed by value, the language doesn't help you. Mutating the symbol-value slot, which is what SET does, the modern way to write (set var val) is (setf (symbol-value var) val), is just that. It's not a general solution. See the articles linked above for a general solution using closure. Which is sophisticated, and demonstrate again that you don't want to do that!
<pjb> There's no point in reproducing the bad things of C in CL! Use CL to write BETTER programs! Don't try to mutate your arguments.
<pjb> Instead, if you insist on using mutation, you can mutate the objects, the _values_ of your parameters.
smasta has joined #lisp
<pjb> (defun my-mutating-fun (v) (incf (aref v 0))) (defvar *vals* (make-array 3 :initial-element 0)) (my-mutating-fun *vals*) *vals* #| --> #(1 0 0) |#
smasta has quit [Ping timeout: 250 seconds]
torbo has joined #lisp
c0mrade has joined #lisp
<c0mrade> I've made an IRC bot that prints to a dot matrix Star printer on its serial port at ##robot, everything you type there is printed to it and it's on Live Stream on YouTube at https://youtu.be/zwRL5V0XWQY
jcowan has joined #lisp
<jcowan> Is it normal for interactive restart handling of USE-VALUE, STORE-VALUE, etc. to evaluate the expression read from the user that specifies the new value?
Jesin has quit [Quit: Leaving]
pankajgodbole has quit [Remote host closed the connection]
<_death> jcowan: yes
<jcowan> Thanks.
<phoe> jcowan: if the user doesn't want it evaluated they can always quote it
* jcowan nods.
<phoe> it's harder the other way around
<jcowan> I am specifying (and will be writing) a TTY-style interactor as part of the Scheme restart package I am also specifying.
<jcowan> However, the current interactor will be held in a dynamic variable so that it can be replaced completely or rebound in a dynamic scope, such as by a TUI, GUI, or browser interactor.
grewal has joined #lisp
<asdf_asdf_asdf> Thanks for help p-j-b.
Jesin has joined #lisp
zotan has quit [Ping timeout: 258 seconds]
zotan has joined #lisp
agspathis has quit [Quit: ERC (IRC client for Emacs 27.0.50)]
smasta has joined #lisp
smasta has quit [Ping timeout: 250 seconds]
elem6 has joined #lisp
ym has quit [Remote host closed the connection]
rozenglass has quit [Read error: Connection reset by peer]
rozenglass has joined #lisp
random-nick has quit [Read error: Connection reset by peer]
elem6 has quit [Ping timeout: 250 seconds]
abhixec has joined #lisp
elazul has joined #lisp
Oladon has joined #lisp
robdog has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
vibs29 has quit [Ping timeout: 245 seconds]
smasta has joined #lisp
vibs29 has joined #lisp
hiroaki has joined #lisp
smasta has quit [Ping timeout: 246 seconds]
rdap has joined #lisp
<rdap> o/
<beach> Hello rdap.
<rdap> And hello to you as well, beach.
<beach> rdap: Are you new here? I don't recognize your nick.
<rdap> I've been here off and on in the past, but I've never really been a regular.
<beach> I see.
<rdap> I might have been using the nick 'caffe' at the time
<beach> That one I think I have seen.
<rdap> I usually tend to come here when i find myself lost with a problem, and I guess this time is no exception.
<beach> Uh, oh.
<rdap> I haven't given up reading just yet, so don't worry.
<beach> If you want me to try to help, you had better state your problem very soon, because I am about to quit in order to go spend my (admittedly small) family.
<beach> But I guess others will help as well.
<phoe> and if not, take your time, and let the rest of #lisp try to help while beach is off IRC
<phoe> oh right exactly that
<rdap> Oh, no worries. It's not urgent, and either I'll figure it out after reading more, or I'll have a more clearly stated problem.
<rdap> s/problem/question
asdf_asdf_asdf has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
themsay has quit [Read error: Connection reset by peer]
<rdap> Right now I'm just debating what approach to take for a conditional loop
<pjb> (cond (test (loop))) what is there to debate?
themsay has joined #lisp
<phoe> rdap: when do you need the test to be evaluated and when do you need to break the loop?
<rdap> i need the test to be evaluated before the loop runs (next), and for it to break there when the condition is met
<phoe> (loop if (foo) do (frob) else (loop-finish))
<phoe> uh, else do (loop finish)
<phoe> or use DO
<rdap> I think I used 'do' last time, and I've been reading over 'loop' today
anewuser has joined #lisp
lemoinem has quit [Ping timeout: 244 seconds]
lemoinem has joined #lisp
<pjb> (defmacro if (test consequent &optional alternative) `(loop repeat 1 if ,test do (progn ,consequent) else do (progn ,alternative)))
<phoe> (incf (smugness 'pjb))
smasta has joined #lisp
<pjb> phoe: this is why sicl implements loop first, and then use it to implement the rest of CL ;-)
ravndal has quit [Quit: WeeChat 2.4]
ravndal has joined #lisp
smasta has quit [Ping timeout: 246 seconds]
nalkri has quit [Ping timeout: 250 seconds]
<rdap> loops almost seem like another language
<phoe> because it is
<phoe> it's a domain-specific language embedded in Lisp
torbo has quit [Remote host closed the connection]
<MichaelRaskin> Just like format, only more powerful
<Grue`> rdap: (loop while test do stuff)
vlatkoB_ has quit [Remote host closed the connection]
lavaflow has quit [Ping timeout: 245 seconds]
abhixec has quit [Ping timeout: 250 seconds]
lavaflow has joined #lisp
bendersteed has quit [Read error: Connection reset by peer]
pagnol has joined #lisp
<pagnol> what are some mature libraries to make a gui with a native look and feel on linux?
<pagnol> I'm returning to cl after a longer hiatus and have no idea what people are using
akoana has joined #lisp
rozenglass has quit [Ping timeout: 250 seconds]
smasta has joined #lisp
meepdeew has joined #lisp
<phoe> pagnol: qtools
smasta has quit [Ping timeout: 272 seconds]
Josh_2 has joined #lisp
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
dale has joined #lisp
<pagnol> by shinmera... this dude is so incredibly prolific
<no-defun-allowed> Yeah, Shinmera has written a lot of good libraries.
<phoe> he is
<phoe> I'm frequently flinging GitHub issues at him
<phoe> s/I'm frequently flinging/I frequently fling/
Oddity has quit []
<jcowan> I thought sicl implemented first mop, then clos, then everything else.
<rdap> i think i got it.. https://pastebin.com/HTRF3HnG
<White_Flame> I thought sicl implemented everything assuming everything else exists
<rdap> there's probably a more elegant way to do it
<phoe> rdap: you don't want DEFVAR in there
<phoe> use LET instead
<phoe> I mean, DEFPARAMETER
<_death> (defun euler-1 () "Return the sum of all natural numbers below 1000 that are multiples of 3 or 5." (loop for x below 1000 when (or (multiple-of-p x 3) (multiple-of-p x 5)) sum x))
<phoe> (multiple-of-p x 3) === (= 0 (mod x 3))
elazul has quit [Quit: leaving]
<no-defun-allowed> zerop?
<phoe> even better
<rdap> phoe: i tried to do it with let, but wasn't able to quite understand it
<phoe> (let ((x 10) (y 20)) (+ x y)) ;=> 30
<rdap> yeah, i saw examples like that but couldn't figure out how to apply it to this
c0mrade has quit [Ping timeout: 272 seconds]
angavrilov has quit [Remote host closed the connection]
<phoe> like this
<caltelt> The most straightforward way: (let ((threes (loop for x.....)) (fives (loop for x ...)) ...)
smasta has joined #lisp
Essadon has quit [Ping timeout: 250 seconds]
<rdap> ahhh, i see now. it can be used with multiple loops.
<pjb> What's the point of sorting before reduce + ?
<rdap> phoe: thank you for that
<pjb> (defun times (n) (lambda (x) (* n x))) (reduce '+ '(3 5) :key (lambda (f) (reduce '+ (mapcar (times f) (iota 1000))))) #| --> 3996000 |#
<rdap> pjb: there really is no point, it's just something that got carried over when i was trying each piece at a time
<pjb> or even (reduce '+ '(3 5) :key (lambda (f) (reduce '+ (iota 1000) :key (times f)))) #| --> 3996000 |#
<pjb> ah, remove-duplicates…
<rdap> i was going to say, that's not right :P
<pjb> Yes.
<pjb> But it's nice :-)
<pjb> (let ((threes (loop for x.....)) (fives (loop for x ...)) ...)
<pjb> *** smasta (~smasta@casewireless09.CWRU.Edu) has joined channel #lisp
<pjb> *** Essadon (~Essadon@81-225-32-185-no249.tbcn.telia.com) has quit: Ping timeout: 250 seconds
<pjb> <rdap> ahhh, i see now. it can be used with multiple loops.
<pjb> <pjb> What's the point of sorting before reduce + ?
<pjb> <rdap> phoe: thank you for that
<pjb> <pjb> (defun times (n) (lambda (x) (* n x))) (reduce '+ '(3 5) :key (lambda (f) (reduce '+ (mapcar (times f) (iota 1000))))) #| --> 3996000 |#
<pjb> <rdap> pjb: there really is no point, it's just something that got carried over when i was trying each piece at a time
<pjb> <pjb> or even (reduce '+ '(3 5) :key (lambda (f) (reduce '+ (iota 1000) :key (times f)))) #| --> 3996000 |#
<pjb> <pjb> ah, remove-duplicates…
<pjb> <rdap> i was going to say, that's not right :P
<pjb> <pjb> Yes.
<pjb> #lisp But it's nice :-)
<pjb> Oops.
<_death> since you're treating them as sets, you can use union
<pjb> But union doesn't ensure unicity.
kushal has quit [Remote host closed the connection]
kushal has joined #lisp
<_death> "If there is a duplication between list-1 and list-2, only one of the duplicate instances will be in the result. If either list-1 or list-2 has duplicate entries within it, the redundant entries might or might not appear in the result."
<_death> so in this case it would work
<pjb> Yes, so from iota this should work. (reduce '+ (union (mapcar (times 3) (iota 20)) (mapcar (times 5) (iota 20)) )) #| --> 1430 |#
<pjb> (reduce '+ (union (mapcar (times 3) (iota 1000)) (mapcar (times 5) (iota 1000)) )) #| --> 3697500 |#
<jcowan> There's a Scheme library that provides both behaviors (treat all elements in an input list as distinct, treat elements in a list as possibly nondistinct). It would be trivial to translate it.
<rdap> answer should be 233168, though
<_death> pjb: your ranges are wrong though
<pjb> Right.
<pjb> (reduce '+ (union (mapcar (times 3) (iota (truncate 1000 3))) (mapcar (times 5) (iota (truncate 1000 5))) )) #| --> 232169 |#
<pjb> actually, I have a iota that does: (reduce '+ (union (iota 1000 0 3) (iota 1000 0 5))) #| --> 3697500 |#
<pjb> (reduce '+ (union (iota (truncate 1000 3) 0 3) (iota (truncate 1000 5) 0 5))) #| --> 232169 |#
bobby has quit [Ping timeout: 250 seconds]
<_death> (collect-sum (choose-if (disjoin (multiple-of 3) (multiple-of 5)) (scan-range :below 1000)))
bobby has joined #lisp
karlosz has joined #lisp
andrei-n has quit [Remote host closed the connection]
torbo has joined #lisp
ltriant has joined #lisp
<grewal> Isn't union inherently slow?
<grewal> (- (+ (loop for x from 0 below 1000 by 3 summing x) (loop for x from 0 below 1000 by 5 summing x)) (loop for x from 0 below 1000 by 15 summing x))
random-nick has joined #lisp
<_death> grewal: since the answer is fixed, just use 233168
lerax has joined #lisp
<grewal> _death: (defun add-multiples-below (p1 p2 bound) "TODO: implement values for other arguments" 233168)
<grewal> like that :p
bobby has quit [Remote host closed the connection]
bobby has joined #lisp
<aeth> The programmatic solution to _death's problem: (defun foo () #.(- (+ (loop for x from 0 below 1000 by 3 summing x) (loop for x from 0 below 1000 by 5 summing x)) (loop for x from 0 below 1000 by 15 summing x))) (disassemble #'foo) (foo)
<aeth> You get a function that constantly returns 233168 with no computation, but *you* don't have to compute it and hardcode it yourself!
<_death> (defmemo solve (problem) (post-question "Hi! ~A" problem) (fetch-top-answer))
shka_ has quit [Ping timeout: 246 seconds]
monokrom has quit [Remote host closed the connection]
bobby has quit [Remote host closed the connection]
bobby has joined #lisp
<Grue`> rdap: (reduce '+ (sort ...)) is redundant because addition is commutative
Oladon has quit [Quit: Leaving.]
DrPete has quit [Ping timeout: 255 seconds]
DrPete has joined #lisp
<Grue`> (flet ((asum (k) (let ((n (floor 1000 k))) (* k (* n (1+ n)) 1/2)))) (+ (asum 3) (asum 5) (- (asum 15))))
benjamin-l has quit [Disconnected by services]
benjamin-l has joined #lisp
benjamin-l has quit [Client Quit]
<Grue`> correction: (* k n (1+ n) 1/2)
orivej has quit [Ping timeout: 246 seconds]
orivej_ has joined #lisp
lavaflow has quit [Read error: Connection reset by peer]
nowhere_man has joined #lisp
meepdeew has quit [Remote host closed the connection]
lavaflow has joined #lisp
<jcowan> I retract my comment that the library would be easy to convert.
jfb4 has quit [Ping timeout: 250 seconds]
hiroaki has quit [Ping timeout: 250 seconds]
jcowan has left #lisp [#lisp]
robdog has joined #lisp
Josh_2 has quit [Quit: ERC (IRC client for Emacs 26.1)]
robdog has quit [Ping timeout: 250 seconds]
random-nick has quit [Read error: Connection reset by peer]
jack_rabbit_ has quit [Ping timeout: 250 seconds]
kajo has joined #lisp
wxie has joined #lisp
ltriant has quit [Quit: .]
wxie has quit [Quit: Bye.]
robdog has joined #lisp
ltriant has joined #lisp
robdog has quit [Ping timeout: 250 seconds]
DrPete has quit [Ping timeout: 250 seconds]
DrPete has joined #lisp
lucasb has quit [Quit: Connection closed for inactivity]
wxie has joined #lisp
longshi has joined #lisp
jack_rabbit_ has joined #lisp
techquila has joined #lisp
Oddity has joined #lisp
Josh_2 has joined #lisp
torbo has quit [Remote host closed the connection]
torbo has joined #lisp
varjag has quit [Quit: ERC (IRC client for Emacs 26.1)]
lumm has quit [Remote host closed the connection]
Aruseus has quit [Remote host closed the connection]
DrPete has quit [Ping timeout: 246 seconds]
polezaivsani has quit [Quit: ERC (IRC client for Emacs 26.1)]
DrPete has joined #lisp
meepdeew has joined #lisp
Kaisyu7 has joined #lisp
torbo has quit [Remote host closed the connection]
Oladon has joined #lisp
didi has joined #lisp
techquila has quit [Read error: Connection reset by peer]
mindthelion has joined #lisp