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
zotan has quit [Ping timeout: 250 seconds]
zotan has joined #lisp
patlv has joined #lisp
Quasus has quit [Ping timeout: 252 seconds]
lucasb has quit [Quit: Connection closed for inactivity]
|3b|` has joined #lisp
|3b| has quit [Ping timeout: 264 seconds]
smasta has joined #lisp
keep_learning has quit [Remote host closed the connection]
smasta has quit [Ping timeout: 250 seconds]
Lord_of_Life_ has joined #lisp
Lord_of_Life has quit [Ping timeout: 252 seconds]
Lord_of_Life_ is now known as Lord_of_Life
rumbler31 has quit [Read error: Connection reset by peer]
mindCrime has joined #lisp
rumbler31 has joined #lisp
smasta has joined #lisp
Oladon has joined #lisp
Achylles has quit [Ping timeout: 252 seconds]
zmt01 has quit [Quit: Leaving]
mindCrime has quit [Ping timeout: 264 seconds]
shifty has joined #lisp
smasta has quit [Ping timeout: 252 seconds]
smasta has joined #lisp
zmt00 has joined #lisp
igemnace has joined #lisp
t58 has quit [Quit: tripped over power cord]
smasta has quit [Ping timeout: 240 seconds]
dale has joined #lisp
keep_learning_M has quit [Ping timeout: 250 seconds]
shifty has quit [Ping timeout: 250 seconds]
impulse has quit [Ping timeout: 250 seconds]
smasta has joined #lisp
keep_learning_M has joined #lisp
caltelt_ has joined #lisp
smasta has quit [Ping timeout: 250 seconds]
mrak has joined #lisp
stux|RC-only has joined #lisp
torbo has left #lisp ["ERC (IRC client for Emacs 26.1)"]
rpg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ebrasca has quit [Remote host closed the connection]
<beach> Good morning everyone!
pillton has joined #lisp
impulse has joined #lisp
Bike has quit [Quit: sleep]
mrak has quit [Remote host closed the connection]
xkapastel has quit [Quit: Connection closed for inactivity]
smasta has joined #lisp
patlv has quit [Ping timeout: 252 seconds]
shifty has joined #lisp
gravicappa has joined #lisp
okeg has quit [Quit: WeeChat 1.6]
rwlisp has quit [Quit: rwlisp]
dddddd has quit [Quit: Hasta otra..]
asarch has joined #lisp
Lord_of_Life has quit [Quit: Laa shay'a waqi'un moutlaq bale kouloun moumkine]
Lord_of_Life has joined #lisp
keep_learning has joined #lisp
pankajgodbole has joined #lisp
Oladon has quit [Quit: Leaving.]
techquila has quit [Ping timeout: 250 seconds]
mulk has quit [Quit: ZNC - http://znc.in]
dgtlcmo has quit [Ping timeout: 250 seconds]
mulk has joined #lisp
dale has quit [Quit: dale]
nwoob has joined #lisp
<nwoob> it is necessary to add . in alist like ((one . 1))
<beach> nwoob: Not in general. What is the situation?
Oladon has joined #lisp
<nwoob> Just saw the erc-autojoin-channels-alist example and it was (("freenode.org" "#emacs"))
<nwoob> but from what I have read in book i have only seen with .
<beach> I think you are confused.
<beach> The CAR of an element of an alist is the key and the CDR of an element of an alist is the value.
<beach> If the element is (KEY . THING) then THING is the value
<beach> If the element is (KEY THING) then (THING) is the value.
<beach> It is that simple.
<beach> So in your example, the value is the list ("#emacs").
<beach> But I imagine there can be more channels.
<beach> So you could have ("freenode.org" "#emacs" "#sicl" "#lisp") in which case the value would be the list ("#emacs" "#sicl" "#lisp")
<beach> nwoob: Does that make sense to you?
<nwoob> so when we want to have more values in THING we write like above instead of cons pair
<beach> If you want a list of things, yes.
<nwoob> ok then I get it
<nwoob> thank you beach
<beach> You can also write ("freenode.org" . ("#emacs" "#sicl" "#lisp")) to emphasize that the value is a list. It's the same thing.
<beach> Anytime.
<beach> nwoob: I think you need to look into how lists are represented as chains of CONS cells. Once you understand that, the above should be obvious.
<nwoob> ok, i will go through the cons pair once again, I knew I didn't got it properly
<beach> nwoob: Do you see how (a . (b c d)) and (a b c d), when read by READ, result in the same constellation of CONS cells?
reverse_light has joined #lisp
<nwoob> yes
<beach> Then you see that the CDR (i.e. the value of the element) is the same in both cases, namely (b c d).
<beach> So there is nothing special about it. Just that in this case, the value is a list rather than an atom.
<nwoob> right yes
ggole has joined #lisp
nwoob has quit [Ping timeout: 264 seconds]
[jlk] has quit [Remote host closed the connection]
khisanth_ has quit [Ping timeout: 246 seconds]
pankajgodbole has quit [Ping timeout: 252 seconds]
khisanth_ has joined #lisp
pankajgodbole has joined #lisp
libertyprime has quit [Ping timeout: 264 seconds]
eschatologist has quit [Ping timeout: 258 seconds]
vlatkoB has joined #lisp
eschatologist has joined #lisp
caltelt_ has quit [Ping timeout: 255 seconds]
scymtym has quit [Ping timeout: 240 seconds]
beach has quit [Disconnected by services]
beach has joined #lisp
Inline has quit [Quit: Leaving]
no-defun-allowed has joined #lisp
<no-defun-allowed> Good afternoon everyone
eschatologist has quit [Quit: ZNC 1.7.1+deb2 - https://znc.in]
eschatologist has joined #lisp
orivej has quit [Ping timeout: 252 seconds]
<beach> Hello no-defun-allowed.
makomo has joined #lisp
<no-defun-allowed> Morning beach! How are you?
<makomo> morning
<loke> hello
<beach> no-defun-allowed: I am fine thank you. And you?
<beach> Hello makomo.
<no-defun-allowed> I'm alright thanks.
rumbler31 has quit [Remote host closed the connection]
<splittist> good morning
<no-defun-allowed> Morning splittist
atgreen_ has quit [Remote host closed the connection]
atgreen_ has joined #lisp
Grue` has quit [Quit: ZNC 1.7.2 - https://znc.in]
rdap has quit [Remote host closed the connection]
Grue` has joined #lisp
rdap has joined #lisp
rme has quit [Read error: Connection reset by peer]
rme has joined #lisp
Kaisyu has quit [Read error: Connection reset by peer]
p_l has quit [Read error: Connection reset by peer]
CEnnis91 has quit [Read error: Connection reset by peer]
l1x has quit [Read error: Connection reset by peer]
Kaisyu has joined #lisp
p_l has joined #lisp
l1x has joined #lisp
CEnnis91 has joined #lisp
didi has joined #lisp
knobo has joined #lisp
q-u-a-n has quit [Read error: Connection reset by peer]
scymtym has joined #lisp
<didi> Is it possible to produce code at every function execution? For example, at https://paste.debian.net/hidden/1f98a75c the recursive LABELS function `sum' has an IF (a COND, really) that depends on the value of wrapping function `my-sum' parameter's `oddp'. The value of `oddp' has been fixed by the caller, so asking about its value at every recursion is unnecessary. I want to get rid of this IF. Maybe I can use some kind of local macro?
<White_Flame> generating code at runtime involves sexpr lists as data, and a call to eval or compile
<didi> White_Flame: oic
<makomo> didi: you can't do it with a macro because macros work at compile-time, and at that moment you have no idea what ODDP is
<didi> makomo: Indeed.
<White_Flame> in ye olde times, there were "fexprs" which were like macros but worked at runtime
<makomo> what White_Flame said -- you need run-time code generation and execution/compilation
<didi> Oh well. I'm unwilling to go that far. Thank you.
<White_Flame> which works perfectly fine if your lisp environment interprets sexprs, but doesn't fit with compiling implementations
<makomo> heh yeah, fexprs. i still have to read kent's paper on that
<White_Flame> in your specific example, didi, you could have sum-odd and sum-even that call each other, as 1- toggles between them. Only the entry point needs to test for oddp
khrbt has quit [Quit: ZNC 1.7.1 - https://znc.in]
<pjb> didi: you can do it by hand of course: https://paste.debian.net/hidden/0fd43f0b/
<pjb> didi: to do it automatically, you'll need some quite smart optimization in the compiler… (because you need to understand the pre/post conditions of the tests!
<didi> White_Flame: Indeed, but I have a more complicated function on hold that needs to know the value of a parameter to decides how to iterate. Because it's in a tight loop, I might duplicate the function and change just where I have to, but I wanted to know if I could avoid it.
<didi> pjb: Thanks.
<White_Flame> compile-time does have a lot of constraints, in not knowing what runtime values will be
* didi nods
<pjb> I would assume that loop unrolling are better optimized than interrecursive functions.
<pjb> So if you wanted the compiler to optimize your code, write it iteratively rather than recursively.
<pjb> Of course, that depends on the compiler.
<pjb> A good lambda-based compiler would do a good job with recursive functions too. (eg. if it's compiling with continuations).
<didi> pjb: Thanks. I like to abuse the stack a lot tho.
asarch has quit [Quit: Leaving]
<didi> Yeah, look, SBCL has very similar functions for reducing from the front (`list-reduce') and reducing from the end (`list-reduce-from-end'). If it's good enough for SBCL...
<ggole> That one is usually called loop unswitching
<didi> ggole: Thank you.
<ggole> It's fairly well known, but many compilers don't try to do such transformations.
<didi> It's nice to know the name of things.
<didi> There's even an wikipedia page for it: https://en.wikipedia.org/wiki/Loop_unswitching
jprajzne has joined #lisp
karlosz has joined #lisp
hajovonta has joined #lisp
<hajovonta> hi all
<no-defun-allowed> hi
liangchao has left #lisp [#lisp]
hhdave_ has joined #lisp
lnostdal has quit [Remote host closed the connection]
fivo has joined #lisp
heisig has joined #lisp
karlosz has quit [Quit: karlosz]
Demosthenex has quit [Remote host closed the connection]
heisig has quit [Quit: Leaving]
Demosthenex has joined #lisp
heisig has joined #lisp
Krystof has quit [Ping timeout: 250 seconds]
Demosthenex has quit [Remote host closed the connection]
Demosthenex has joined #lisp
gareppa has joined #lisp
knicklux has joined #lisp
Ukari has quit [Remote host closed the connection]
Ukari has joined #lisp
gravicappa has quit [Ping timeout: 264 seconds]
rumbler31 has joined #lisp
igemnace has quit [Quit: WeeChat 2.4]
rumbler31 has quit [Ping timeout: 264 seconds]
hajovonta has quit [Ping timeout: 250 seconds]
<no-defun-allowed> is there a function in CL that finds the duplicate elements in a list? eg (find-duplicates '(1 2 3 1)) => (1)
<beach> I don't think so.
<beach> But it is easy to write.
orivej has joined #lisp
<no-defun-allowed> Well, I suppose I'll do that then.
<no-defun-allowed> That was pretty simple, you're right.
<fivo> Is it possible to get the LAMBDA-LIST and the info like COMPILED FUNCTION shown by (describe 'symbol)?
<fivo> I am on SBCL
<loke> fivo: Well, you can play with FUNCTION-LAMBDA-EXPRESSION
<loke> it's not guaranteed to return anything though.
<scymtym> also CL:COMPILED-FUNCTION-P
lnostdal has joined #lisp
keep_learning has quit [Remote host closed the connection]
adip has quit [Ping timeout: 252 seconds]
gareppa has quit [Quit: Leaving]
reverse_light has quit [Ping timeout: 264 seconds]
ealfonso has joined #lisp
madmuppet006 has joined #lisp
m00natic has joined #lisp
ealfonso has quit [Read error: Connection reset by peer]
ealfonso has joined #lisp
Ukari has quit [Ping timeout: 240 seconds]
SaganMan has joined #lisp
Ukari has joined #lisp
ealfonso has quit [Ping timeout: 264 seconds]
ealfonso has joined #lisp
no-defun-allowed has quit [Remote host closed the connection]
shifty has quit [Ping timeout: 240 seconds]
ealfonso has quit [Ping timeout: 250 seconds]
ealfonso has joined #lisp
dddddd has joined #lisp
ealfonso has quit [Ping timeout: 250 seconds]
ealfonso has joined #lisp
terpri has quit [Remote host closed the connection]
terpri has joined #lisp
ealfonso has quit [Read error: Connection reset by peer]
ealfonso has joined #lisp
rdap has quit [Remote host closed the connection]
rdap has joined #lisp
ealfonso has quit [Read error: Connection reset by peer]
gareppa has joined #lisp
ealfonso has joined #lisp
amerlyq has joined #lisp
ealfonso has quit [Read error: Connection reset by peer]
ealfonso has joined #lisp
__jrjsmrtn__ has joined #lisp
ealfonso has quit [Read error: Connection reset by peer]
ealfonso has joined #lisp
amerlyq has quit [Quit: amerlyq]
Essadon has joined #lisp
Essadon has quit [Max SendQ exceeded]
xkapastel has joined #lisp
thijso has joined #lisp
bon` has joined #lisp
<jackdaniel> complex float operations improvements in ECL: http://hellsgate.pl/files/2542707e-report.html (no optimizations in compiler yet whatsoever, just generic dispatch on math operations). still behind sbcl though :c
<jackdaniel> mandelbrot/dfloat is put there for scale, we should do much better job with double floats too
heisig has quit [Quit: Leaving]
orivej has quit [Ping timeout: 264 seconds]
orivej has joined #lisp
varjag has joined #lisp
ealfonso has quit [Read error: Connection reset by peer]
atgreen_ has quit [Ping timeout: 268 seconds]
ealfonso has joined #lisp
varjag has quit [Client Quit]
amerlyq has joined #lisp
varjag has joined #lisp
orivej has quit [Ping timeout: 246 seconds]
patlv has joined #lisp
patlv has quit [Ping timeout: 252 seconds]
<beach> jackdaniel: Congratulations!
wigust has joined #lisp
wigust- has quit [Ping timeout: 245 seconds]
bon` has quit [Ping timeout: 264 seconds]
patlv has joined #lisp
amerlyq has quit [Quit: amerlyq]
dgtlcmo has joined #lisp
LiamH has joined #lisp
orivej has joined #lisp
amerlyq has joined #lisp
varjag has quit [Ping timeout: 252 seconds]
<jackdaniel> beach: thank you :)
atgreen_ has joined #lisp
Bike has joined #lisp
Lord_of_Life has quit [Ping timeout: 264 seconds]
Lord_of_Life has joined #lisp
Inline has joined #lisp
random-nick has joined #lisp
selwyn has joined #lisp
patlv has quit [Quit: patlv]
q9929t has joined #lisp
dgtlcmo has quit [Ping timeout: 264 seconds]
okeg has joined #lisp
q9929t has quit [Quit: q9929t]
<jackdaniel> I've put results in clim app: https://imgur.com/drAprZJ.png (numbers are little different - I've run it again and removed dfloat)
lucasb has joined #lisp
mindCrime has joined #lisp
SaganMan has quit [Quit: WeeChat 1.6]
smasta has quit [Ping timeout: 252 seconds]
Kevslinger has joined #lisp
ealfonso has quit [Read error: Connection reset by peer]
smasta has joined #lisp
ealfonso has joined #lisp
quazimodo has joined #lisp
smasta has quit [Ping timeout: 264 seconds]
rumbler31 has joined #lisp
<mgsk> I have some dir `./src/contribs` that contains things like plugins that depend on the main library. I want these to be loaded whenever the main library is loaded. Is this something that ASDF can deal with?
ealfonso has quit [Ping timeout: 264 seconds]
rumbler31 has quit [Ping timeout: 246 seconds]
<mgsk> I guess just doing `(:file ...)` would suffice in that case. I was expecting something more complicated
<mgsk> e.g. I don't know ahead of time what is in the contribs dir, so I can't write out all the appropriate `(:file ...)`forms.
<jackdaniel> a few months back I wrote an "autodiscovery" module class for someone, link should be somewhere in logs
rwlisp has joined #lisp
<mgsk> jackdaniel: interesting. Thanks!
xylef has joined #lisp
xylef has quit [Client Quit]
madmuppet006 has quit [Remote host closed the connection]
xylef has joined #lisp
xylef has quit [Client Quit]
madmuppet006 has joined #lisp
scymtym has quit [Ping timeout: 268 seconds]
knobo has quit [Ping timeout: 264 seconds]
xylef has joined #lisp
brundleticks has quit [Remote host closed the connection]
sjl_ has quit [Quit: WeeChat 2.3-dev]
FreeBirdLjj has joined #lisp
sjl has joined #lisp
dale has joined #lisp
madmuppet006 has quit [Remote host closed the connection]
FreeBirdLjj has quit [Ping timeout: 264 seconds]
rippa has joined #lisp
dgtlcmo has joined #lisp
nowhereman has joined #lisp
ricekrispie has joined #lisp
Zaab1t has joined #lisp
dale has quit [Quit: dale]
gareppa has quit [Quit: Leaving]
t58 has joined #lisp
igemnace has joined #lisp
Oladon has quit [Ping timeout: 252 seconds]
madmuppet006 has joined #lisp
didi has left #lisp ["O bella ciao bella ciao bella ciao, ciao, ciao."]
dale has joined #lisp
nowhereman has quit [Ping timeout: 252 seconds]
shifty has joined #lisp
Achylles has joined #lisp
nowhereman has joined #lisp
lumm has joined #lisp
vaporatorius has joined #lisp
nowhereman has quit [Ping timeout: 250 seconds]
nowhereman has joined #lisp
shka_ has joined #lisp
Oladon has joined #lisp
rumbler31 has joined #lisp
kajo has quit [Ping timeout: 264 seconds]
rumbler31 has quit [Remote host closed the connection]
rumbler31 has joined #lisp
jprajzne has quit [Quit: jprajzne]
rumbler31 has quit [Ping timeout: 250 seconds]
xylef has quit [Quit: WeeChat 2.4]
nowhereman has quit [Ping timeout: 264 seconds]
hhdave_ has quit [Ping timeout: 246 seconds]
abhixec has joined #lisp
smasta has joined #lisp
lucasb has quit [Quit: Connection closed for inactivity]
smasta has quit [Ping timeout: 255 seconds]
m00natic has quit [Remote host closed the connection]
selwyn has quit [Remote host closed the connection]
jgodbou has quit [Ping timeout: 256 seconds]
smasta has joined #lisp
rumbler31 has joined #lisp
MichaelRaskin has joined #lisp
karlosz has joined #lisp
rdap has quit [Remote host closed the connection]
rdap has joined #lisp
xylef has joined #lisp
nanoz has joined #lisp
andrei-n has joined #lisp
dacoda has joined #lisp
shifty has quit [Ping timeout: 250 seconds]
karlosz has quit [Quit: karlosz]
makomo has quit [Quit: WeeChat 2.2]
amerlyq has quit [Ping timeout: 252 seconds]
smasta has quit [Ping timeout: 240 seconds]
pankajgodbole has quit [Ping timeout: 264 seconds]
smasta has joined #lisp
dvkt has joined #lisp
amerlyq has joined #lisp
fivo has quit [Quit: WeeChat 1.9.1]
smasta has quit [Ping timeout: 264 seconds]
smasta has joined #lisp
rdap has quit [Remote host closed the connection]
rdap has joined #lisp
orivej has quit [Ping timeout: 252 seconds]
ricekrispie has quit [Quit: 0111001101101000011001010110010101100101011001010110100101110100]
ricekrispie has joined #lisp
smasta has quit [Ping timeout: 264 seconds]
nanoz has quit [Ping timeout: 268 seconds]
heisig has joined #lisp
heisig has quit [Remote host closed the connection]
random-nick has quit [Read error: Connection reset by peer]
nowhere_man has joined #lisp
CrazyEddy has quit [Ping timeout: 245 seconds]
knicklux has quit [Remote host closed the connection]
Zaab1t has quit [Quit: bye bye friends]
andrei-n has quit [Read error: Connection reset by peer]
random-nick has joined #lisp
vlatkoB has quit [Remote host closed the connection]
Jesin has quit [Quit: Leaving]
fiveop has joined #lisp
Jesin has joined #lisp
atgreen_ has quit [Ping timeout: 264 seconds]
Bike has quit []
amerlyq has quit [Ping timeout: 252 seconds]
amerlyq has joined #lisp
xylef has quit [Quit: WeeChat 2.4]
ym555 has joined #lisp
sjl_ has joined #lisp
Achylles has quit [Remote host closed the connection]
Achylles has joined #lisp
kajo has joined #lisp
Krystof has joined #lisp
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
smasta has joined #lisp
angavrilov has quit [Remote host closed the connection]
smasta has quit [Ping timeout: 264 seconds]
Bike has joined #lisp
wilfredh has quit [Quit: Connection closed for inactivity]
runbmp has joined #lisp
LiamH has quit [Quit: Leaving.]
ggole has quit [Quit: Leaving]
vms14 has joined #lisp
<vms14> guys how can I make a list from the input?
<vms14> I want symbols, but the read just only works for one atom or list
<vms14> and read-line takes a string
<vms14> I have no idea how to convert a string to a list of symbols, I just take the first element
<aeth> (intern "FOO") => FOO
<vms14> How can I read symbols until newline and cons them?
<vms14> aeth: tried inter
<aeth> (intern "foo") => |foo|
<vms14> intern*
<aeth> You need to upcase if you want behavior like regular Common Lisp
<vms14> it's nice, but it converts several atoms into one
<aeth> (intern (string-upcase "foo")) => FOO
<vms14> so I just get one symbol instead of many
<aeth> vms14: So the problem is that you're reading in a line into a string, and you're turning "Hello world" into |Hello world| instead of (HELLO WORLD)
<vms14> I'd like to read until newline
<aeth> Correct?
<vms14> and get a list of atoms
<vms14> aeth: yes
orivej has joined #lisp
<vms14> I'm trying to parse input, I just want read every symbol from the input until the user press enter
<vms14> I guess I don't need to go for read-char
<aeth> You're going to need to use LOOP here
<vms14> I'm using a loop
mindCrime has quit [Ping timeout: 246 seconds]
<vms14> I want to make some kind of parser for the bad html generator I try to do
<vms14> I just want to parse input and do stuff like "h1 hi"
<vms14> but I prefer symbols instead of strings
<aeth> vms14: One thing you could do, and it's quite a hack, is (read-from-string (read-line))
<pjb> vms14: you can use (read-from-string (read-line))
<pjb> vms14: or rather: (read-from-string (validate (read-line)))
<vms14> the thing is usually I won't know how many symbols will be, and the delimiter is the newline
<aeth> vms14: the second value in read-from-string is where it left off so you can loop on that second value
<vms14> what does validate?
<pjb> vms14: or: (loop for element = (extract-one-item (read-line)) until (eof-element-p element) collect element)
amerlyq has quit [Ping timeout: 250 seconds]
<vms14> I've tried to mix read-from-string with read-line
<vms14> maybe I did it wrong
amerlyq has joined #lisp
<pjb> vms14: using READ or READ-FROM-STRING, you allow input to do whatver it wants with your lisp image, by default.
xkapastel has quit [Quit: Connection closed for inactivity]
<vms14> I like the last one pjb
<aeth> vms14: (read-from-string (read-line)) for a line "hello world" will return (values HELLO 5)
<pjb> vms14: consider: (read-from-string "#.(delete-file \"~/your-important-file.txt\")"
amerlyq has quit [Client Quit]
<aeth> vms14: you can then do (read-from-string (read-line) nil nil :start 5) to get (values WORLD 11)
<aeth> it's really weird to see optional followed by keyword
<pjb> So you would want to bind *read-eval* to NIL. but other reader macros can be problematic: (read-from-string "#8931289312839012*") for example, could DOS your system by trying to allocate all its RAM. (or just signal a condition, depending on the implementation).
atgreen_ has joined #lisp
<vms14> oh, nice hack
<aeth> yes, never trust user input.
<pjb> another thing is that reading symbols will intern them, so if there's a loop, the input could fill your memory with useless symbols.
<pjb> So you might want to intern the symbols in a throw away package that you can delete-package when you're done.
<aeth> vms14: The "correct" (safe) way to do things is to parse the string, perhaps with cl-ppcre
<pjb> (in the loop).
<pjb> or keep strings, not symbols. strings are garbage collected when lost.
<aeth> By the time you add in the validation pjb is talking about, the parse solution probably becomes more concise than the elegant solution that pjb and I both said simultaneously
<pjb> Exactly! :-)
dgtlcmo has quit [Quit: leaving]
moldybits has quit [Read error: Connection reset by peer]
<pjb> vms14: (split-sequence #\space (read-line) :remove-empty-subseqs t) is usually all you need.
<aeth> or split with cl-ppcre
<aeth> Which to use is debatable. split-sequence is a smaller dependency, but if you're doing additional parsing, you might be using cl-ppcre anyway
<pjb> (ql:quickload :split-sequence) (use-package :split-sequence) (with-input-from-string (*standard-input* "Hello world! How do you do?") (split-sequence #\space (read-line) :remove-empty-subseqs t)) #| --> ("Hello" "world!" "How" "do" "you" "do?") ; 27 |#
moldybits has joined #lisp
<vms14> I prefer symbols rather to strings if possible
<vms14> isn't it better choice?
<aeth> The third option is to split manually with position
<pjb> vms14: possibly, use uninterned symbols?
<pjb> Then they can be garbage collected just like strings.
<vms14> unevaluated symbols
<pjb> But since symbols have a name that is a string, they're a bigger overhead.
<vms14> and convert them to string when needed
dacoda has quit [Ping timeout: 268 seconds]
<pjb> So use symbols only if you need their features: interned, plist, value, function, etc.
<nirved> what is an "evaluated symbol"?
<vms14> I was thinking symbols were cheaper than a string
<vms14> nirved: an unquoted one
<pjb> Nope.
<aeth> If you wanted "absolutely 0" overhead, you can get that. Well, not quite 0, you'd have to track start and end positions for each substring. String/sequence functions take in start and end so you can just work like that.
<vms14> so then just go for strings?
CrazyEddy has joined #lisp
<vms14> and read-line
<aeth> vms14: symbols are cheaper when they're already there
<aeth> so writing :hello and :world right in your code
<nirved> vms14: unquoted symbol can be many things at the same time
<pjb> (com.informatimago.common-lisp.cesarum.array:positions #\space "Hello world! How do you do?") #| --> (5 12 16 19 23) |#
<vms14> thanks for the hints
<vms14> I'll just do it with strings
<pjb> (let ((string "Hello world! How do you do?")) (loop :for start := 0 :then (1+ end) :for end :in (com.informatimago.common-lisp.cesarum.array:positions #\space string) :collect (cons start end) :into result :finally (return (nconc result (list (cons end (length string))))))) #| --> ((0 . 5) (6 . 12) (13 . 16) (17 . 19) (20 . 23) (23 . 27)) |#
<aeth> You could store positions in an array with the :element-type alexandria:array-index, which will probably round up to fixnum or "unsigned fixnum" (it will show up as some strange looking unsigned-byte size like (unsigned-byte 62)) or (in 64-bit implementations) (unsigned-byte 64)
<pjb> And then you can use (foo string :start (car pos) :end (cdr pos)) with most sequence functions to process the substrings. Or (subseq string (car pos) (cdr pos)) when you need to extract it.
<pjb> (which you may not have to).
<aeth> You could also do that as two vectors or two lists, one for start position and one for end position. (I think to make the vector, the best solution would be to walk the string twice, first to get the length for the allocated vectors and then to set the elements)
<pjb> vms14: Notice that displaced arrays just abstract those (car pos) (cdr pos) bounds. So instead of subseq, you can use (make-array (- (cdr pos) (car pos)) :element-type (array-element-type string) :displaced-to string :displacement-offset (car pos))
<aeth> Two lists or two vectors means you could e.g. use map with a lambda of two inputs.
<vms14> there was a function to separate strings using a delimiter right?
<vms14> like spaces
<aeth> there's two, one is split-sequence:split-sequence the other is cl-ppcre:split
<aeth> well, two popular ones
<vms14> I should start soon using ppcre
<vms14> regex are very important stuff, and I've read ppcre is a nice library
<aeth> the alternative is to allocate a list or vector of positions, or, as I recently noticed, two sequences instead of one
<aeth> s/cl-ppcre:split/ppcre:split/
<vms14> Package SPLIT-SEQUENCE does not exist.
<vms14> this is sbcl
<aeth> (ql:quickload :split-sequence)
<vms14> just tried (split-sequence:SPLIT-SEQUENCE #\Space "A stitch in time saves nine.")
<vms14> oh, I thought there it was a standard function
<vms14> tnx xD
<aeth> splitting isn't the standard way to think about things, the standard way to think about things is with positions, which is why every built-in (and every well-behaved library) has start/end or start1/end1/start2/end2
<aeth> (either as optional or keyword)
<aeth> s/every built-in/every sequence built-in/
<aeth> At least for strings.
<vms14> I guess I'll end using read-char
<aeth> the easiest no-library way to do it is probably read-line and do position tracking, but read-char will probably be the most efficient solution
<pjb> Even cl-ppcre:scan actually returns positions (any regexp library does).
<aeth> Thinking about lists can be done with splitting without a library, but only in one direction, splitting the front parts off and keeping the tail.
<pjb> Depending on the size of the string and the substrings, displaced arrays may spare a lot of RAM. However, in the substrings are short, then subseq will be more efficient both in time and space. (eg. on a 64-bit system, we can assumme that strings up to 8 or 16 bytes (2-4 unicode characters) are better created rather than (list* string start end) or displaced arrays.
abhixec has quit [Remote host closed the connection]
<aeth> vms14 might not need a subseq/displacement at all, if it's about determining what to do based on user commands.
<aeth> e.g. a state machine could be used on read-char
<vms14> it will be a bad html generator taking short strings
<aeth> ah, html
<pjb> But don't write the state machine by hand! Write a state machine compiler from a high level description!
<aeth> you said that once already but I missed it, my bad
<vms14> yeah, I want to make a transpiler to c, starting with easy stuff like create a variable, output the value, etc
<aeth> at least you're generating html, not parsing it.
<aeth> it's easy to write valid html, and hard to accept all valid html
<vms14> but first I want learn lisp and make a html generator as exercise
<vms14> did you made your toy language?
<vms14> should be hard to do stuff like scoping and worse in more advanced stuff
<aeth> I have a partially complete GLSL generator so I can already essentially transpile to C if I spent a few weeks on it. Very similar syntax.
<vms14> pjb: nah, I want to learn lisp by making this generator
<aeth> Generally, people avoid the parsing problem altogether when generating another language and just work directly in s-expressions
<vms14> if not, I guess I would be using cl-who
<pjb> Sure but read it to choose its design!
<pjb> Well, no, you wouldn't use cl-who. Read the document!
<vms14> aeth: right, being lisp so mutable is easy to make a dialect
<vms14> but I guess it's also one of the best languages to make a parser
<vms14> someone said prolog is better
<aeth> vms14: the problem is that 90% of the cases where you'd need parsers in other languages, people just avoid them altogether in Lisps and start with s-expressions, so there's probably less work on parsers than you might expect
<aeth> s/that 90%/that in 90%/
<vms14> yeah, but I want to make a transpiler
runbmp has left #lisp ["WeeChat 2.4"]
<vms14> well, I want to try it
<vms14> xD
<vms14> also sure lisp is nice to make one IDE
<pjb> Yep.
<vms14> atm I just want to start with html, and maybe later add stuff like some variables
<aeth> vms14: Almost every "transpiler" in Common Lisp starts with s-expressions. If you don't want to start with s-expressions, you should probably act like you're doing the exact same thing as the normal transpilers and use this as the intermediate format.
<aeth> Start with s-expression->target then do input->s-expression as the next step
<vms14> what I had is a function wrapping the input from read-line with parens using concatenate 'string xD
<aeth> Lisp itself was written in this way. m-expressions were the next step. https://en.wikipedia.org/wiki/M-expression
<vms14> and evaluating those expressions
<vms14> but what I want to do with lisp atm is some sort of lex generated program
<aeth> This sort of thing in Lisp is always done in at least two stages, where the first stage parses to s-expressions and the last stage turns a direct (or near-direct) s-expression mapping into strings like (:+ 1 2 3) into "(1 + 2) + 3"
<aeth> The last stage is usually written first because it is pretty trivial.
<aeth> In fact, + is probably one of the harder ones. Mostly you just go (:foo 1 2 3) to "foo(1, 2, 3)" with the only real difficulty being the way to generate the names (e.g. does foo-bar become "fooBar"?)
shifty has joined #lisp
sjl has quit [Quit: WeeChat 2.3-dev]
sjl_ has quit [Quit: WeeChat 2.2-dev]
sjl has joined #lisp
digash has joined #lisp
<grewal> /scrollback goto -100
<grewal> Not again :(
<vms14> (read-delimited-list #\Newline)
<vms14> does not work with newline
* t58 feels grewal's pain from here
* vms14 cries
digash has left #lisp [#lisp]
digash has joined #lisp
digash is now known as dig`
shka_ has quit [Ping timeout: 252 seconds]
moei has quit [Quit: Leaving...]
<grewal> vms14: Wouldn't (read-from-string (read-line)) do what you want (read-delimited-list #\Newline) to do?
<vms14> grewal: that will just return the first atom
<vms14> (loop while (not (char= #\Newline (peek-char))) do (push (read) input))
<vms14> tried this, but it needs to newlines
<vms14> two*
random-nick has quit [Ping timeout: 252 seconds]
<pjb> vms14: you could make read-delimited-list #\newline work. For this, you need to copy the character syntax from #\) to #\newline.
<pjb> theorically. It stil doesn't work :-( (let ((*readtable* (copy-readtable))) (set-syntax-from-char #\newline (character ")") (with-input-from-string (*standard-input* (format nil "hello world~%How do you do~%")) (values (read-delimited-list #\newline) (read-delimited-list #\newline)))) #| ERROR: Unexpected end of file on #<string-input-stream :closed #x3020025DED1D> |#
CrazyEddy has quit [Remote host closed the connection]
orivej has quit [Ping timeout: 250 seconds]
<vms14> seems to work
<vms14> but it's very dirty
CrazyEddy has joined #lisp
<grewal> Why doesn't a split function approach work?
<vms14> it works
<vms14> but wanted to do it without libraries
CrazyEddy has quit [Remote host closed the connection]
<grewal> Does that do what you want?
<vms14> now I just need to change it in order to just intern the first word
<grewal> I should have used collect instead of push
<vms14> grewal: it does not work
<vms14> it works on your machine?
<vms14> oh, yeah it does
<grewal> It runs, and it gives me what I expect. I don't know if it's what you expect
<vms14> yeah, it does what I want
<vms14> (test (read-line)) but seems to yield strange results with this
<vms14> lol, nvm it works well
<vms14> xD
<vms14> tnx
CrazyEddy has joined #lisp
<vms14> I love how format lets you write in fill-pointer strings
karlosz has joined #lisp
<vms14> and there are more things I'm missing about format, I need to practice a bit with things like ~:* and so on
<pjb> vms14: your last paste is crazy.
<vms14> pjb: that's my code and also why I cannot say I'm a programmer
<vms14> xD
<vms14> but usually this happens when I'm testing stuff and patching things over and over
<vms14> anyway it's not an excuse, I do not know yet how to write nice code
<vms14> and my code usually is slow, walking around because I'm noob and idk the direct way
<pjb> and it doesn't seem to work that well.
<vms14> xD what I want is the input var
<vms14> inputstring it's useless, and I shouldn't be using it
<vms14> also I should be using let
<vms14> I shouldn't be coding yet, but I want to get used to lisp, and the best way is coding
CrazyEddy has quit [Remote host closed the connection]
<vms14> hope with the time your eyes stop bleeding with my code xD
<grewal> What do you mean by "I shouldn't be coding yet"?
<vms14> grewal: I mean I should be reading and doing test stuff and wait a bit to make this program
<vms14> also I still thinking the On lisp book should teach me nice things, but I need to understand lisp better before this book, or I'll miss some important stuff
<vms14> and have the PAIP waiting too
patlv has joined #lisp
<pjb> vms14: loop is nice because it's versatile. Instead of having loops for, while, until, etc, loop does everything. (loop :while … :do …) (loop :do … :until …) (loop :for i :from 0 :to 10 :do …) and other variants: (loop :while … :do … :until …) (loop :do … :while … :do …) etc.
<pjb> vms14: note that the :finally clause is jumped to as soon as one terminating clause is validated. So (loop … :until … :do … :finally …) doesn't evaluate :do when the :until condition is true.
CrazyEddy has joined #lisp
<aeth> vms14: what do you want your input to look like?
patlv has quit [Ping timeout: 250 seconds]
<aeth> What makes LOOP good for reading is its behavior for :for ... := ... is different than DO's behavior when you do not have an iteration step. With LOOP, it will do the thing initially and then repeat it, with DO it will only do it once so you wind up having to repeat yourself twice (once for the initial value and once for the step) unless you abstract over this with a custom macro.
<aeth> So even if you're primarily using DO and/or DO* in your coding style, this is one of those good exceptions where you should use LOOP
lumm has quit [Remote host closed the connection]
<aeth> (correction for the nitpickers, you repeat yourself once, which is writing the same code twice, you don't "repeat yourself twice")
<vms14> pjb: nice code, I'll save it
<pjb> or you can write (do ((i #1=(read) #1#)) ((null i)) (print i))
<vms14> aeth: idk, I guess what I really want is just a list of atoms being read from input
<vms14> but I need to learn more
<pjb> And it's safe: (with-input-from-string (input " #.(delete-file \"~/.bashrc\")") (read-token-list input)) #| --> ("#.(delete-file" "\"~/.bashrc\")") |#
<aeth> vms14: Imo, you shouldn't think in terms of "list of atoms being read from input" imo. That's eval()-style behavior (CL's EVAL is different, and eval("1 + 1") in other languages is closer to (eval (read-from-string "(+ 1 1)")) in CL)
<aeth> vms14: You should be thinking in terms of what kind of syntax you want to support, and parsing that syntax.