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
rumbler31 has quit [Remote host closed the connection]
igemnace has quit [Quit: WeeChat 2.4]
keep_learning has joined #lisp
bexx has quit [Remote host closed the connection]
anewuser has joined #lisp
atgreen has joined #lisp
sjl_ has quit [Ping timeout: 246 seconds]
smasta has joined #lisp
smasta has quit [Ping timeout: 246 seconds]
Lord_of_Life has quit [Ping timeout: 246 seconds]
smasta has joined #lisp
Lord_of_Life has joined #lisp
caltelt_ has quit [Ping timeout: 245 seconds]
smasta has quit [Ping timeout: 268 seconds]
grewal has quit [Quit: leaving]
lucasb has quit [Quit: Connection closed for inactivity]
rumbler31 has joined #lisp
t58 has quit [Quit: Night All]
rumbler31 has quit [Ping timeout: 245 seconds]
khisanth_ has quit [Ping timeout: 245 seconds]
karlosz has joined #lisp
dddddd has quit [Remote host closed the connection]
khisanth_ has joined #lisp
milanj has quit [Quit: This computer has gone to sleep]
keep_learning has quit [Remote host closed the connection]
keep_learning has joined #lisp
esrse has joined #lisp
akoana has joined #lisp
smasta has joined #lisp
makomo has quit [Ping timeout: 246 seconds]
smasta has quit [Ping timeout: 250 seconds]
refpga has quit [Remote host closed the connection]
smasta has joined #lisp
smasta has quit [Ping timeout: 245 seconds]
karlosz has quit [Quit: karlosz]
torbo has quit [Remote host closed the connection]
patlv has quit [Quit: patlv]
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 268 seconds]
<beach> Good morning everyone!
smasta has joined #lisp
Bike has quit [Quit: Lost terminal]
smasta has quit [Ping timeout: 250 seconds]
anewuser has quit [Ping timeout: 246 seconds]
karlosz has joined #lisp
karlosz has quit [Client Quit]
aeth has quit [Ping timeout: 268 seconds]
nanoz has joined #lisp
aeth has joined #lisp
smasta has joined #lisp
smasta has quit [Ping timeout: 255 seconds]
p0a has joined #lisp
<p0a> Hello
<beach> Hello p0a.
<p0a> Is sbcl + emacs slime the right way to go about writing CL in debian?
<p0a> I'm familiar with emacs but it's been so long I've done some CL that I don't know what' sup
<p0a> checking cliki.net now
<beach> I don't know about Debian in particular, but that combination is probably the most frequently used by #lisp participants.
<p0a> beach: and quicklisp right?
<beach> Right.
vlatkoB has joined #lisp
<beach> p0a: What kind of programs are you planning to write?
adip has quit [Ping timeout: 268 seconds]
q-u-a-n has joined #lisp
<p0a> beach: I want to record some numbers from shapes in the plane
<p0a> beach: for example, generate a random triangle, record its angles. something like that
<p0a> I'm being a bit vague
<beach> I think I understand.
<p0a> It won't be deep stuff unfortunely. It's just that CL is convenient for me
<p0a> because I don't like having to use all the different syntaxes there are out there
<p0a> I have to go, thanks for the help
p0a has quit [Quit: bye]
karlosz has joined #lisp
p0a has joined #lisp
<p0a> Hello again, why is slime-mode not indending my code? I tried to load slime-fancy...
smasta has joined #lisp
rumbler31 has joined #lisp
smasta has quit [Ping timeout: 245 seconds]
xkapastel has quit [Quit: Connection closed for inactivity]
<loke> p0a: are you pressing TAB to indent
<p0a> loke: I was being silly and not using `lisp-mode'! sorry!
nanozz has joined #lisp
nanoz has quit [Ping timeout: 246 seconds]
<p0a> How can I LOOP over three lists simultaneously?
<p0a> (loop for i in list1 ... j in list2 ... etc)
<p0a> but I don't want to have them run concurrently. I realize I can have 3 loop macros but I'm just wondering
<beach> You want them nested?
<beach> Then you nest your LOOP.
<p0a> Example?
<beach> If you describe your problem more in detail, it might be easier to help.
<p0a> I want to loop over a list L with three variables i, j,k and collect (list i j k)
<p0a> I don't mind some repeats
caltelt_ has joined #lisp
<beach> Loop over three lists or one list?
<p0a> one list
<beach> So you want all combinations of three elements?
<p0a> yeah
<beach> If the list is (a b c d) you want ((a a a) (a a b) (a b a)...)?
<p0a> yeah
<p0a> Ideally I'd like only unique ones but I can filter them later
<beach> You need three nested loops then.
<p0a> i.e. (a b c) (a b d) (b c d) (a c d)
<p0a> alright
<p0a> but my collect's will be nested
<p0a> I can flatten later but is it easy to do it inside loop?
Ricchi has joined #lisp
<beach> (loop with result = '() for i in list do (loop for j in list do (loop for k in list do (push (list i j k) result))) finally (return result))
<p0a> aah with push. nice
<p0a> I'm not thinking
grumble has quit [Quit: If we're putting dbus in the linux kernel, I want a Java RMI registry there too.]
<beach> With some slight variation, you could uniquify at the same time.
<p0a> thanks a lot!
<beach> Sure.
<loke> you could also use nconc
<p0a> nconc?
<p0a> sounds like n-concatenate?
<loke> (loop for ... nconc (loop ... nconc (loop ... collect (list i j k))))
<loke> Just in case you don't want push on result
<p0a> ah, I see
<p0a> so that's part of the macro, nice
Ricchi has quit [Quit: Leaving]
grumble has joined #lisp
<beach> p0a: (loop for (i . ii) on list nconc (loop for (j . jj) on ii nconc (loop for k in jj collect (list i j k))))
<beach> That way you don't have to uniquify afterwards.
nanozz has quit [Read error: Connection reset by peer]
smasta has joined #lisp
<p0a> huh not sure what you did there
<p0a> also, is there a way to check if a list of bools is all true without REDUCEing over AND?
<p0a> Maybe I can just use loop actually
<loke> p0a: You can't reduce over AND (and is a special form)
<loke> or rather, amcro
<beach> clhs every
<loke> What you want is EVERY
<loke> (every #'identity LIST)
smasta has quit [Ping timeout: 246 seconds]
<p0a> I can use NEVER or EVERY, nice, thank you
Inline has quit [Quit: Leaving]
<beach> p0a: All I did was to use the remaining list in the nested loops, rather than the entire list.
<p0a> hm
<p0a> so what about the previous values ?
smasta has joined #lisp
<p0a> ooh that's qhy it's unique, nice
makomo has joined #lisp
sauvin has joined #lisp
smasta has quit [Ping timeout: 268 seconds]
<p0a> beach: that's very nice, thanks!
<p0a> I now understand that you're using `on' to go through the list one cdr at a time
<beach> Yes.
Arcaelyx has quit [Quit: Textual IRC Client: www.textualapp.com]
igemnace has joined #lisp
<p0a> alright, have to go. Thank you a lot
<beach> Anytime.
p0a has quit [Quit: bye]
libertyprime has quit [Ping timeout: 245 seconds]
smasta has joined #lisp
sr5h has joined #lisp
jprajzne has joined #lisp
cyraxjoe has quit [Ping timeout: 268 seconds]
smasta has quit [Ping timeout: 245 seconds]
cyraxjoe has joined #lisp
scymtym has quit [Ping timeout: 246 seconds]
<pjb> (defun combinations (list n) (cond ((zerop n) '()) ((= 1 n) (mapcar (function list) list)) (t (mapcan (lambda (rest) (mapcan (lambda (first) (list (cons first rest))) list)) (combinations list (1- n)))))) (combinations '(a b c) 3) #| --> ((a a a) (b a a) (c a a) (a b a) (b b a) (c b a) (a c a) (b c a) (c c a) (a a b) (b a b) (c a b) (a b b) (b b b) (c b b) (a c b) (b c b) (c c b) (a a c) (b a c) (c a c) (a b c) (b b c) (c b c) (a
<pjb> (b c c) (c c c)) |#
khisanth_ has quit [Ping timeout: 246 seconds]
sr5h has quit [Ping timeout: 255 seconds]
<splittist> top o' the mornin'
Josh_2 has joined #lisp
ltriant has quit [Quit: leaving]
<loke> splittist: what?
libertyprime has joined #lisp
Lycurgus has joined #lisp
khisanth_ has joined #lisp
nowhereman has quit [Ping timeout: 258 seconds]
angavrilov has joined #lisp
scymtym has joined #lisp
orivej has joined #lisp
vhost- has quit [Quit: WeeChat 2.5-dev]
heisig has joined #lisp
<Josh_2> top 'o the mornin to ya splittist
smasta has joined #lisp
Elronnd has quit [Remote host closed the connection]
smasta has quit [Ping timeout: 245 seconds]
smasta has joined #lisp
smasta has quit [Ping timeout: 246 seconds]
__jrjsmrtn__ has joined #lisp
karlosz has quit [Quit: karlosz]
ricekrispie has quit [Read error: Connection reset by peer]
fivo has joined #lisp
milanj has joined #lisp
akoana has left #lisp ["Leaving"]
smasta has joined #lisp
lonjil2 has quit [Ping timeout: 258 seconds]
smasta has quit [Ping timeout: 250 seconds]
lonjil has joined #lisp
pjb has quit [Ping timeout: 252 seconds]
pjb has joined #lisp
fanta7531 has joined #lisp
ricekrispie has joined #lisp
atgreen has quit [Ping timeout: 240 seconds]
smasta has joined #lisp
rumbler31 has quit [Remote host closed the connection]
atgreen has joined #lisp
Lycurgus has quit [Ping timeout: 245 seconds]
smasta has quit [Ping timeout: 250 seconds]
edgar-rft has quit [Quit: Leaving]
caltelt_ has quit [Ping timeout: 250 seconds]
esrse has quit [Ping timeout: 250 seconds]
akater has joined #lisp
__jrjsmrtn__ has quit [Ping timeout: 255 seconds]
__jrjsmrtn__ has joined #lisp
Essadon has joined #lisp
nwoob has joined #lisp
libertyprime has quit [Read error: Connection reset by peer]
libertyprime has joined #lisp
smasta has joined #lisp
smasta has quit [Ping timeout: 246 seconds]
nwoob has quit [Ping timeout: 264 seconds]
hhdave has joined #lisp
themsay has joined #lisp
wigust- has quit [Read error: Connection reset by peer]
themsay has quit [Read error: Connection reset by peer]
wigust has joined #lisp
themsay has joined #lisp
smasta has joined #lisp
smasta has quit [Ping timeout: 244 seconds]
milanj has quit [Quit: This computer has gone to sleep]
grewal has joined #lisp
igemnace has quit [Quit: WeeChat 2.4]
milanj has joined #lisp
dddddd has joined #lisp
nwoob has joined #lisp
gjvc has joined #lisp
themsay has quit [Quit: Quit]
amerlyq has joined #lisp
Lycurgus has joined #lisp
ggole has joined #lisp
libertyprime has quit [Ping timeout: 246 seconds]
smasta has joined #lisp
xkapastel has joined #lisp
smasta has quit [Ping timeout: 246 seconds]
nwoob has quit [Ping timeout: 250 seconds]
libertyprime has joined #lisp
atgreen has quit [Ping timeout: 250 seconds]
orivej has quit [Ping timeout: 268 seconds]
smasta has joined #lisp
Bike has joined #lisp
smasta has quit [Ping timeout: 268 seconds]
LiamH has joined #lisp
Lord_of_Life_ has joined #lisp
Lord_of_Life has quit [Ping timeout: 255 seconds]
Lord_of_Life_ is now known as Lord_of_Life
AdmiralBumbleBee has quit [Ping timeout: 255 seconds]
nirved is now known as Guest93169
Guest93169 has quit [Killed (niven.freenode.net (Nickname regained by services))]
atgreen has joined #lisp
nirved has joined #lisp
AdmiralBumbleBee has joined #lisp
libertyprime has quit [Quit: leaving]
ebrasca has quit [Remote host closed the connection]
fanta7531 has quit [Quit: fanta7531]
nwoob has joined #lisp
patlv has joined #lisp
warweasle has joined #lisp
q9929t has joined #lisp
q9929t has quit [Quit: q9929t]
nwoob has quit [Ping timeout: 268 seconds]
dale_ has joined #lisp
dale_ is now known as dale
FreeBirdLjj has joined #lisp
FreeBirdLjj has quit [Ping timeout: 252 seconds]
nowhereman has joined #lisp
jayemar has joined #lisp
pjb has quit [Remote host closed the connection]
heisig has quit [Quit: Leaving]
powerbit has quit [Remote host closed the connection]
sjl_ has joined #lisp
sjl_ has quit [Client Quit]
sjl_ has joined #lisp
scymtym has quit [Ping timeout: 258 seconds]
varjag has quit [Quit: ERC (IRC client for Emacs 25.2.2)]
rumbler31 has joined #lisp
nowhereman has quit [Ping timeout: 246 seconds]
rumbler31 has quit [Ping timeout: 255 seconds]
aeth has quit [Ping timeout: 246 seconds]
pjb has joined #lisp
orivej has joined #lisp
aeth has joined #lisp
heisig has joined #lisp
igemnace has joined #lisp
rumbler31 has joined #lisp
rippa has joined #lisp
eddof13 has joined #lisp
eddof13 has quit [Client Quit]
jprajzne has quit [Quit: Leaving.]
eddof13 has joined #lisp
shifty has quit [Ping timeout: 245 seconds]
lumm has joined #lisp
heisig has quit [Remote host closed the connection]
Lycurgus has quit [Quit: Exeunt]
mindCrime has joined #lisp
shka_ has joined #lisp
Achylles has joined #lisp
edgar-rft has joined #lisp
ogamita has joined #lisp
gxt has joined #lisp
__jrjsmrtn__ has quit [Read error: Connection reset by peer]
hiroaki has quit [Ping timeout: 250 seconds]
ggole has quit [Quit: Leaving]
Inline has joined #lisp
hhdave has quit [Ping timeout: 250 seconds]
fivo has quit [Quit: WeeChat 1.9.1]
ebrasca has joined #lisp
gareppa has joined #lisp
gxt has quit [Quit: WeeChat 2.4]
karlosz has joined #lisp
karlosz has quit [Client Quit]
makomo has quit [Quit: WeeChat 2.2]
ricekrispie has quit [Quit: 0111001101101000011001010110010101100101011001010110100101110100]
samlamamma has joined #lisp
<samlamamma> You know, Lisp is really the ultimate CRUD-application builder. Just provide the definition of your data and Lisp can generate all the code to transfer it between your app, the database, the protobuf layer, what have you.
lucasb has joined #lisp
<shka_> well, you can generate bullshit code, that's true
<shka_> good evening
<samlamamma> shka_: Yes, and I'm sitting here writing bullshit code instead.
gareppa has quit [Quit: Leaving]
milanj has quit [Quit: This computer has gone to sleep]
zotan has quit [Ping timeout: 240 seconds]
atgreen has quit [Ping timeout: 245 seconds]
zotan has joined #lisp
* beach wonders whether samlamamma is Swedish.
asarch has joined #lisp
<shka_> oh, you didn't knew CRUD
<beach> No, I don't do databases.
<shka_> lucky you
<beach> Yes, I am lucky that I can choose what to work on.
Achylles has quit [Ping timeout: 250 seconds]
samlamamma has quit [Ping timeout: 246 seconds]
<jackdaniel> crud(l) is also aften used in api context (i.e RESTful API)
t58 has joined #lisp
<beach> REST is another one that I only learned about not too long ago.
Jesin has quit [Quit: Leaving]
warweasle has quit [Quit: meeting]
<beach> Databases seem to imply copying, and copying is contrary to the semantics of Common Lisp, so I am trying to figure out ways of managing data without copying it.
<beach> ... like universal persistence for instance.
nanoz has joined #lisp
smasta has joined #lisp
<shka_> beach: yeah, you see this is stuff used to build every single webapp, and since it is used to build every single webapp efforts has been made to make it painless even though it still sucks
<shka_> … i just realized that it sounds like unix
<beach> Heh, yes.
<shka_> anyway, my point is that most people don't care
<shka_> *most people doesn't care
<beach> don't
<beach> Plural.
<shka_> effort has been made
<beach> Anyway, I am off to spend time with my (admittedly small) family.
<shka_> good night
<shka_> don't put to much effort into thinking about databases
<shka_> at this point potential for the change is minimal, everybody wants to have database in a separate docker etc.
<shka_> it is overly complex and wastes people time but it was tamed so nobody cares anymore
Jesin has joined #lisp
sauvin has quit [Read error: Connection reset by peer]
<asarch> Everybody should write his own Lisp, at least once in the life
ogamita has quit [Ping timeout: 240 seconds]
<asarch> And when you write your own implementation, how do you know if it is 100% compatible with the standard?
<jackdaniel> how does doatabase imply copying?
<asarch> Are there any tests about it?
<jackdaniel> asarch: there are ansi-tests written by pfdietz, they are very useful when looking for non-conformities
<shka_> asarch: T
Achylles has joined #lisp
vlatkoB has quit [Remote host closed the connection]
<grewal> asarch: Bootstrap another implementation and run their tests
smasta has quit [Ping timeout: 255 seconds]
<p_l> beach: have you seen GemStone/S? While it's proprietary, the source should be interrogatable at runtime, and it's based about object persistence at language level, iirc
karlosz has joined #lisp
karlosz has quit [Client Quit]
karlosz has joined #lisp
k-hos has joined #lisp
warweasle has joined #lisp
keep_learning_M has quit [Ping timeout: 250 seconds]
karlosz has quit [Quit: karlosz]
rumbler31 has quit [Remote host closed the connection]
keep_learning_M has joined #lisp
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
kenu has joined #lisp
hiroaki has joined #lisp
makomo has joined #lisp
knicklux has joined #lisp
kenu has quit [Ping timeout: 246 seconds]
eddof13 has quit [Quit: eddof13]
vms14 has joined #lisp
eddof13 has joined #lisp
<vms14> It is right what lispers say about lisp changes your mind
<vms14> It's too soon for me to have changed, but I start to see how you change your mind gradually while learning lisp
<vms14> I guess the first step is realizing everything is made of abstractions and the way you don't care about non-yet-defined things. But I cannot explain it well since I'm only having a little taste of common lisp
cantstanya has quit [Remote host closed the connection]
aeth has quit [Ping timeout: 255 seconds]
aeth has joined #lisp
varjag has joined #lisp
nanoz has quit [Quit: Leaving]
knicklux has quit [Remote host closed the connection]
angavrilov has quit [Remote host closed the connection]
<aeth> vms14: It's kind of the opposite of abstractions here. Almost every other language offers heavily abstracted syntax.
rumbler31 has joined #lisp
<vms14> I mean, you make your way with abstractions
<vms14> and lisp is one of the best languages for creating abstraction
<aeth> for foo[42] instead of (aref foo 42) and saving maybe half a second of typing and a few characters, you lose a lot, particularly the ability to conveniently define your own syntactic abstractions
<vms14> having abstractions limits you
<vms14> but creating them is what we do more or less in almost every program
zotan has quit [Ping timeout: 252 seconds]
<aeth> Well, I mean, many languages are stuck with (aref (aref foo 42) 15) instead of (aref foo 42 15) because they're stuck with foo[42][15] instead of having a true foo[42,15] or whatever because that would require new syntax
<vms14> I like C because it lets or even forces me to build things from almost the scratch
<aeth> So even in my simple example what seems harder winds up being more powerful because it's extensible
<vms14> lisp not only lets me build, it also has a lot of builtin functions prepared just to create abstraction
zotan has joined #lisp
rumbler31 has quit [Ping timeout: 246 seconds]
<vms14> I mean, since the first time I saw lisp in lisp books or tutorials, I saw lispers are making the pieces more little than what I usually see
<aeth> The slightly more inconvenient syntax encourages more abstractions, too.
<aeth> You see stuff like with-accessors
<vms14> idk how to explain, but In C one function usually does one thing
<vms14> in lisp one function also does one thing ( if the programmer wants ) but it does that thing using a lot of functions which usually are not builtin functions, but created by the programmer
<vms14> every function is a layer or a step to reach the goal
<vms14> things are more modular
<aeth> You can write Lisp in any language. I certainly layer my trivial functions Lisp-style even in C
<vms14> so you made your mapcar in C
<aeth> No, I mean layers of functions (though higher order functions is, of course, a Lisp feature)
<aeth> You can e.g. do most of the input error checking in one function and then a function unencumbered by that noise that just implements the logic.
<vms14> I'm just trying to make some sort of transpiler to C
<aeth> Each function being trivial, short, and doing one simple thing is very Lisp-style
<vms14> doing noob stuff like creating functions for declare a variable and sum that variable
<aeth> You *can* do syntactic abstraction in C but don't. Lisp has many advantages over C there. Yes, at that point, just transpile and use s-expressions as your actual source.
<vms14> xD
<vms14> I was wondering if read from input or wrap the input with parens
<vms14> so the user is actually calling functions without knowing it
<vms14> but I guess I'll start with just the (read) function which gives me symbols and start parsing symbols
<vms14> I need to learn how to parse, and I'll cry when things go more complicated, but it's just for fun and I'll learn by the way
<aeth> vms14: oh please don't do that (adding implicit ()s around foo to make (foo) and then calling it), that's basically as safe as calling eval() in other languages
<vms14> xD
<aeth> Just have one giant case
<aeth> something like this: (case (car input) (foo (foo (elt input 1) ...
<vms14> I'll start reading symbols and converting symbols to string when needed with (string symb)
xkapastel has quit [Quit: Connection closed for inactivity]
shka_ has quit [Ping timeout: 245 seconds]
<vms14> It will take time to do that, and I want to do first one html generator to practice
<vms14> but I want start soon at least trying to bind variables and how to organize data
<vms14> I guess the thing I like more of programming is metaprogramming and ai
xkapastel has joined #lisp
hiroaki has quit [Ping timeout: 252 seconds]
<aeth> vms14: can you describe exactly what you're trying to do?
eddof13 has quit [Ping timeout: 245 seconds]
<vms14> aeth: learn common lisp
<vms14> I'd like to use common lisp as a parser sooner or later, so while I'm a noob I try to at least do noob stuff
<vms14> also I want to see how lisp changes my mind as a programmer
<vms14> and every day I learn about lisp I like it more
<vms14> <3
cranes has joined #lisp
smasta has joined #lisp
jayemar has quit [Quit: afk]
vms14 has quit [Quit: WeeChat 2.3]
interruptinuse has joined #lisp
mindCrime has quit [Ping timeout: 255 seconds]
kajo has joined #lisp
amerlyq has quit [Quit: amerlyq]
Achylles has quit [Ping timeout: 252 seconds]
Arcaelyx has joined #lisp
Bike has quit []
LiamH has quit [Quit: Leaving.]
<makomo> huh damn, cl-ppcre is such a magical and beautiful thing :-)
<makomo> just when i thought i ran into an ""issue"" with its property resolvers, edi has already thought of it https://edicl.github.io/cl-ppcre/#*property-resolver*
<makomo> note the ";; quiz question - why do we need CREATE-SCANNER here?" :-)
<makomo> a very good quiz question actually
<makomo> hint: compiler macros and LOAD-TIME-VALUE
<makomo> my usage was (let ((cl-ppcre:*property-resolver* ...)) (ppcre:scan <string> <string>))
<makomo> also, a very cool late night regex trick: splitting using zero-width positive lookaheads -- use the regex "(?=<delimiter>)"
<makomo> the fact that it's zero-width means that it doesn't actually remove the delimiter
<makomo> the cool thing is that you can use literally any regex for <delimiter>, including stuff like character properties. that way you can split on uppercase letters and such, without removing them
rumbler31 has joined #lisp
karlosz has joined #lisp
rumbler31 has quit [Ping timeout: 245 seconds]
milanj has joined #lisp
karlosz has quit [Quit: karlosz]
wxie has joined #lisp
lumm has quit [Quit: lumm]
nowhereman has joined #lisp
sjl_ has quit [Ping timeout: 245 seconds]
smasta has quit [Ping timeout: 245 seconds]
klltkr has joined #lisp
smasta has joined #lisp
varjag has quit [Quit: ERC (IRC client for Emacs 26.1)]
jdz has quit [Ping timeout: 244 seconds]
smasta has quit [Ping timeout: 255 seconds]
rumbler31 has joined #lisp
Essadon has quit [Quit: Qutting]
rumbler31 has quit [Ping timeout: 245 seconds]
karlosz has joined #lisp
jdz has joined #lisp
didi has joined #lisp
<didi> What is the rationale for REDUCE calling FUNCTION with no arguments? I understand the situation (no initial value and empty sequence), but I've never encountered a situation where I wanted it to happen.
<pjb> didi: (+) #| --> 0 |# (*) #| --> 1 |#
<didi> pjb: Interesting.
<pjb> (defun cons* (&optional (a nil ap) d) (if ap (cons a d) '())) (reduce (function cons*) '(1 2 3 4)) #| --> (((1 . 2) . 3) . 4) |#
<pjb> Bad example.
<pjb> (defun cons* (&optional (a nil ap) d) (if ap (cons a d) 'ha)) (reduce (function cons*) '()) #| --> ha |#
<pjb> didi: basically, the function without argument returns the neutral element for the operation, so that reduce can return something meaningful when you call it with an empty list and no :initial-value argument.
<didi> pjb: I usually put the "neutral element" on :INITIAL-VALUE. Maybe I should rethink it.
<pjb> Unfortunately, the function is not called with a singleton: (reduce (function cons*) '(1)) #| --> 1 |#
<pjb> or more: (reduce (function cons*) '(1 2)) #| --> (1 . 2) |#
<pjb> We would like ((1 . ha) . 2)…
<pjb> (reduce (function cons) '(1 2) :initial-value 'ha) #| --> ((ha . 1) . 2) |#
<pjb> or ((ha . 1) . 2).
<didi> pjb: Your #'+ and #'* examples are better. This manufactured one isn't convincing.
<pjb> didi: as you can see, there's a semantic difference between the neutral element and :initial-value.
<pjb> didi: yes. But the same differences exist with them: (reduce '+ '(0 0) :initial-value 42) #| --> 42 |# (reduce '+ '()) #| --> 0 |#
<didi> pjb: Yes, but (reduce '+ '() :initial-value 42) => 42.
<pjb> (reduce '+ '() :initial-value 33) #| --> 33 |#
<pjb> Indeed.
<didi> So I can always say (reduce '+ '() :initial-value 0) -> 0
<pjb> It seems safer to always give an :initial-value indeed.
<pjb> Then you can have any function and any list, and the function can take 2 mandatory arguments.
<didi> That's what I do.
rumbler31 has joined #lisp
nowhereman has quit [Ping timeout: 258 seconds]
<didi> I guess by always passing the neutral element to :initial-value I betray the black box that should be FUNCTION.
<pjb> Yes, but notice how it is semantically different.
<pjb> reduce should call (funcall f) always (funcall f (first list) (funcall f initial-value (funcall f()))) …
<pjb> well, if it did we could do without :initial-value.
<didi> pjb: Sometimes I have crazy :initial-values. I doubt I could do without it.
wxie has quit [Ping timeout: 250 seconds]
nai has left #lisp [#lisp]
techquila has quit [Ping timeout: 240 seconds]
nai has joined #lisp
asarch has quit [Quit: Leaving]
karlosz has quit [Quit: karlosz]
karlosz has joined #lisp
xkapastel has quit [Quit: Connection closed for inactivity]
Bike has joined #lisp
sz0 has quit [Quit: Connection closed for inactivity]
atgreen has joined #lisp