freenode/#lisp - IRC Chatlog
Search
14:27:11
phoe
You get some Lisp forms as input, are able to perform arbitrary computations on them, and return the result as Lisp forms.
14:27:47
phoe
But you have all of Lisp available when you do macroexpansion, just like during runtime, compile-time, read-time.
14:28:18
phoe
oh, SRS. It's Turing complete, but it doesn't have anything to do with Lisp macros, I think.
14:42:11
pjb
phoe: I wouldn't be so sure. If you write (let ((string (make-array +infinite-size+ :element-type 'character))) (format string "…" string)), perhaps something can be done?
14:43:25
pjb
(let ((string (make-array 100 :element-type 'character :fill-pointer 3))) (replace string "abc") (format string "~S" string) string) #| --> "abc\"abc\"" |#
14:45:16
phoe
pjb: that's exactly the problem with format. The lists passed to it as arguments are immutable by FORMAT itself.
15:30:09
phoe
I think (if foo 't 'nil) would be *the* most idiomatic and correct, since you explicitly want the symbols T and NIL
15:30:19
makomo
phoe: i guess, but that reminds me of "if (x > y) return true; else return false;" instead of just "return x > y;"
15:31:17
makomo
Shinmera: well, for example, say i want to test whether a given string is an email address
15:31:21
phoe
if you want either the symbol T or the symbol NIL, then (if foo 't 'nil) conveys exactly this meaning
15:31:31
makomo
i can use cl-ppcre on it, but i want to return just T/NIL, and not cl-ppcre's matches and stuff
15:31:51
makomo
even if i wrapped cl-ppcre:scan's into (values), i would still get the first "match-begin" value
15:35:11
Shinmera
makomo: No, the point of explicitly returning NIL/T. If you document that it's a boolean, it's fine to return generalised booleans.
15:40:10
Shinmera
I'm much more in the camp of "conciseness" than "explicitness" myself, but it's just different ideals.
15:40:36
Shinmera
So if you want to return explicit booleans sure. Just better be consistent about it.
15:45:05
impaktor
Slightly shameful question/offer, but: I have an article that's about to be published in Scientific Reports (accepted, I just got the proof back for final check, called "Fitting a function to time-dependent ensemble averaged data"), and in it I have the sentence "Computer codes are freely available (Python, Octave/matlab, and Lisp)". My intention was to put "Common Lisp", but I got stuck when porting python's numpy method calls to
15:45:15
impaktor
I eventually gave up and ported the Python code to Hy Lisp, because I do want my article to mention there's code in "Lisp". If anyone feels up to tinker with it, I have both working python and hy lisp code here: https://github.com/impaktor/wlsice
15:46:08
impaktor
Anyway, I'm tired of fighting this code, so just thought I'd throw it out as a last check here.
15:50:06
pjb
makomo: the most direct from the user point of view, and assuming a dumb compiler would be (if b 't 'nil). But (not (null b)) (or (not (not b))) would also be nice if you have a good compiler, eg. a compiler that is able to deal with machine booleans, and who understand what (not (null b)) mean (but then, if it knew, it would also know about (if b 't 'nil)). On different processors, there booleans can be represented differently.
15:50:06
pjb
Eg. on 680x0, they're #x00 or #xFF and the boolean instructions (such as the Scc instructions) produce those values. https://stackoverflow.com/questions/25035030/understanding-the-scc-instructions-of-68000-assembly?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
16:12:53
pierpal
and you may want to add a comment clarifying that this conversion has only an aesthetical purpose when using the function in the repl. otherwise readers, including you at a later time, will wonder why you did that
16:28:23
pjb
in any case, I would write a functional abstraction. (defun bool (x) (not (not x))) (declaim (inline bool)) (defun foop (x) (bool (some-predicate-foo x)))
17:01:23
pfdietz
I'd prefer if functions that return generalized booleans return T for true. In general, more specific provided behavior for an interface is good, unless there's a significant reason for that not to be the case.
17:02:16
pfdietz
It's an example of the Robustness Principle. https://en.wikipedia.org/wiki/Robustness_principle
17:11:53
phoe
I might do a lightning demo of the working fork of Reddit 1.0 that has emerged, https://github.com/tamurashingo/reddit1.0/
17:12:22
phoe
absolutely not my work and I take no credit for it, but I think it would be worthy to quickload it, run it, and do some silly things in the web browser
18:11:20
phoe
"there's only three people on the Internet: you, me, and this guy who types really fast"
18:23:42
makomo
phoe: hey that's pretty neat. i saw that the reddit 1.0 code was out but didn't know someone made it work
18:24:10
phoe
pfdietz: some code changes to make it work on non-CMUCL, reconstructing the database schema
18:48:46
Shinmera
Though actually the current 1.1 release was erroneously built on 10.12 and thus doesn't run on 10.11. There's a 1.1b release though that does run on 10.11: https://github.com/portacle/portacle/releases/tag/1.1b
18:49:18
Shinmera
I did build it with travis on 10.10, which works, but 10.9 gives errors from brew about it no longer being supported and I didn't want to care to try and make it work.
19:08:39
pfdietz
(scrolls back in log) That unicode's case mapping is not 1-1 doesn't prevent it from working with a comformant Common Lisp, I think. Those beyond-standard characters just aren't treated as having Common Lisp case.
20:11:58
phoe
Okay. You'll hear from me again when I'm waiting for my plane in Warsaw. Over and out.
21:40:43
drunk_foxx[m]
Lexical scope: let, defun, lambda, let over lambda, let over lambda over let over lambda, etc.
21:40:44
drunk_foxx[m]
Dynamic scope - special variables (defined with defvar), and their value can be "overwritten" within the lexical scope
21:41:40
drunk_foxx[m]
First 6 chapters are for free on his website (including the one about lexical and dynamic scoping)
21:45:29
phoe
iqubic: they do not need to. *FOO* is a special variable, as proclaimed by DEFVAR. it means that now all bindings of that symbol are dynamic.
21:45:56
pfdietz
Lexical shadowing is shadowing according to position in the code. Dynamic variable shadowing is according to position in the stack.
21:49:23
pfdietz
In the lexical case the symbol 'x' goes away entirely, typically, except if the compiler has kept the name around for debugging and such.
21:51:12
pfdietz
I believe they are also typically thread-local, although that's not in the standard.
22:26:37
comborico
Can't find the answer to this: 9 / 4 . nine is the dividend, four is the divisor, 2 is the quotient, and one is the remainder. But what is it called when you carry the remainder over to as in 2 1/4?
23:38:10
aeth
comborico: 2 1/4 is a mixed fraction or mixed number. https://en.wikipedia.org/wiki/Fraction_(mathematics)#Mixed_numbers
23:38:56
aeth
Three names on Wikipedia. The one I learned (a very long time ago) was "mixed fraction" iirc.
0:06:43
krwq
are there any good libraries for 2d matrices (not expecting larger matrices than 1000x1000), only need multiplication, addition and some kind of elementiwise map? I've tried magicl but it seems super unfinished, and supporting only complex matrices although seems like it's under development and calls into lapack
0:22:19
pierpa
I'm not sure that for 1000x1000 matrices, sophisticated methods are faster. Are you better informed than me about this?
0:24:24
pierpa
it looks like that for 1000x1000 Strassen may be useful, according to https://stackoverflow.com/questions/22807065/where-is-strassens-matrix-multiplication-useful
0:27:38
krwq
pierpa: seems like n^2.373 is the fastest: https://en.wikipedia.org/wiki/Coppersmith%E2%80%93Winograd_algorithm
0:29:06
krwq
I think naive might do in this case unless there is some ready solution then I'd go with that
0:29:31
pfdietz
Yeah, you have to be careful with algorithms. Constants matter, sometimes more than non-constant factors.
0:31:03
pfdietz
For matrices the bigger wins are in exploiting sparsity, and in block-structuring the computation to take advantage of caches (and also pipelining).
0:34:48
pierpa
krwq: how fast is at multiplying 1000x1000 something that must be optimized for this, say, matlab or mathematica?
0:35:48
krwq
pierpa: do not have matlab at this point, I remember back when I used it it was fairly instant, it's a good point
0:39:36
pfdietz
There was some excitement in combinatorics a couple of years ago related to a problem that had implications for matrix multiplicaton.
0:40:05
pfdietz
If the conjecture (the Erdos-Szemeredi Sunflower Conjecture) had been false, it could have been possible to multiply matrices in O(n^2) operations.