freenode/#lisp - IRC Chatlog
Search
14:10:37
_death
there could be a ROBUST-CL that specifies much more comprehensive behavior with regards to errors
14:12:27
tumdum
jackdaniel: e.g. http://tilde.cat/~t/tmp/day2.go vs https://git.sr.ht/%7Ettt/aoc18/tree/fe45caaf00bb487dde683cee552d19611fa0de37/day2.lisp
14:13:40
jackdaniel
tumdum: important point was to see code produced by two different people (who seem to favour other languages)
14:14:21
jackdaniel
what may be a hint, that you have more experience with these languages (than with cl)
14:14:28
tumdum
sure, I'm just sharing *my* solutions. You can compare them with whatever you want :)
14:17:21
dim
well it's the same approach in tumdum Go's implementation and my CL one, so I would guess it takes about the same time
14:18:31
dim
my puzzle takes about 8ms to solve in CL; then again we might have large differences in the number of iterations required to find a solution in our respective puzzles, so…
14:20:43
tumdum
'cat day2.input | time -v ./day2 2>&1 | grep "User time"' results in "User time (seconds): 0.00" ;)
14:20:55
_death
anyway, here is mine https://gist.github.com/death/df37a5f5218eaef229f9358412b54f33 .. I just spend a few minutes after brushing my teeth in the morning :d
14:21:55
jackdaniel
I had a benchmarking game today (against myself though): https://files.mastodon.social/media_attachments/files/008/350/509/original/09baa41f5212cffd.png
14:23:16
jackdaniel
(here is some more information: https://mastodon.social/@jackdaniel/101171161106313135)
14:24:21
dim
_death: I kind of like the simplicity of (some (lambda (letter) (= (count letter str) n)) str), even though it's O(n²)
14:28:28
dim
that's what I like with CL in those puzzle, you can be pretty stupid and have no issues out of it
14:41:01
_death
I think every year there's one day with a problem that's not so trivial, around the 20th day
14:56:03
tumdum
_death: for me the hardest problem last year was day3: https://adventofcode.com/2017/day/3 :D
14:59:49
tumdum
afair I constructed actual 'grid', you can check it here: https://github.com/tumdum/aoc2017/blob/master/03/main.rs
15:03:30
makomo
after it wasn't going quite according to plan, i went on to do something else and forgot about aoc
16:09:44
dim
well from reading the article about Taxicab geometry on Wikipedia, it seems that a solution for AOC/2017/d3 would be to generate the coordinates of the number on thr grid and then take the sum of the absolute values of them, that's it (with e.g. 3 being at (1,1) and 21 being at (-2,-2))
16:10:24
dim
maybe I'm missing something, but it doesn't look like you need to actually traverse the spiral, only to obtain the coordinates of 1 and the number in argument
17:01:07
sindan
I'm using slime on emacs; I wonder if it's possible to declare a function/macro with &rest, that when written on the repl does not show its signature in the minibuffer, namely &rest forms, but a custom string that better reminds me of what the function expects in reality
17:09:45
flip214
sindan: then name the &rest parameter so it makes sense? "list-of-key/value-pairs"?
17:11:02
sindan
but then the parameter gets a stupid name and the parameter list can be much more complex than a plist
17:14:51
sindan
putting that info in a specially formatted line in the docstring and retrieving it in elisp could be a start
17:15:35
ggole
elisp itself allows arg-list formatting hints in the docstring, but I don't think slime has that
17:17:57
sindan
if I ever want to get to know emacs/slime that's a project. Sadly I need to resort to &rest when the combination of other param types is so awkward
17:20:52
sindan
even with allow-other-keys, combining &rest with &key can avoid parameters in key position to be keywords, but the number of parameters must be even if &key is present, which is not general enough
17:34:14
_death
I guess that's why there are two parts.. the second can sometimes disagree with the first one's approach and the programmer has to scramble to solve it quickly
17:35:28
dim
I was already contemplating that you only need to keep 2 rows of the spiral and have 5 cells to look at max at each turn
17:46:26
_death
interesting that so many solutions used letter->frequency mapping.. I didn't even get to think of it because I thought the my inefficient was sufficient ;)
17:49:10
alandipert
Afterward I realized I was worrying too much about perf and it definitely interfered with my flow. Tomorrow: KISS
18:26:56
dim
I think I could now easily have a spiral builder that takes a thunk as a parameter and apply it to both the puzzles, but I'm not that interested into it
18:28:29
dim
and 2017/d03/p2 took 334 microseconds (0.000334 seconds) to run, with 10,544 bytes of memory allocated.
18:33:58
_death
hmm, (measure-run-time (neighbors-sum 265149)) => (38 :MICROSECONDS 115 :NANOSECONDS) and (measure-run-time (compute-first-square-larger-than 265194)) => (34 :MICROSECONDS 924 :NANOSECONDS)
18:36:51
dim
SBCL reports that Evaluation took: 0.000 seconds of real time 0.000152 seconds of total run time (0.000151 user, 0.000001 system) 100.00% CPU 458,782 processor cycles 32,768 bytes consed
18:39:57
dim
I just was somewhat proud of my trick where I can do a single incf for a whole spiral side at a time rather than moving only one step per loop
18:44:11
dim
oh I use that all the d03p1 puzzle doesn't use that, that's the second puzzle where I did it, and I think it's very badly written too
18:46:00
_death
if-do-else-do would make that clearer (different semantics, but correct in this case), if you insist on loop ;)
18:49:55
dim
_death: https://github.com/dimitri/AdventOfCode/commit/af3b178bd903d3dee2a715bd30df352f5b8511b8
18:52:40
tumdum
Xach: is it possible to get http://verisimilitudes.net/acute-terminal-control.asd into quicklisp?
19:54:47
jcowan
beach: As usual, the mundane world is only now catching up to what the Lisp world has had for years
20:01:39
jcowan
Frankly, what you have hold of for Sicl is genuinely groundbreaking for a HLL. If I believed in software patents, and if you hadn't disclosed all over the Internet already, I'd say: patent it.
20:53:24
jackdaniel
point being made is that such patents are obstacles to getting things better (but may be a good idea to get wealthy) and I'm quite sure beach pursues better software and not a patent portfolio
20:55:12
jackdaniel
and as of 20y, it is enough to skip whole generation of people to work on something, so from a lifetime perspective it isn't "nope :)"
21:04:44
no-defun-allowed
jackdaniel: private property and personal property are distinct, usually disjoint sets though
21:05:43
no-defun-allowed
and well they call it intellectual property and put property laws on ideas quits often
21:11:57
jcowan
I said "if I believed in patents", which I don't. I mean that beach's idea is both original and useful, and it's not surprising that nothing like it appears in the literature
21:12:47
jcowan
(Actually, I believe that people who want patents and copyrights should pay heavily for them, preferably an annual fee.)
21:14:12
p_l
jcowan: a good patent system is a boon to innovation, but a certain patent system backed by significant military was designed more for stealing ideas and mercantilist blocking of foreign companies
21:15:56
jcowan
Patents are monopolies, and monopolists should pay for what they are (for sound economic reasons) allowed to deprive the rest of us of, to wit, the market value of the monopolized article.
21:16:59
p_l
jcowan: patent system origins in Europe were for monopoly-breaking by putting incentiving people to use patents rather than keeping things secret
21:17:34
p_l
because a proper patent should have all the details necessary to reproduce the invention patented + a reasonable time limit
21:20:52
p_l
beach: what was the "fast module"? I looked at scrollback but I'm missing some context and it seems interesting
21:21:57
no-defun-allowed
p_l: I think it’s not taking time to consider better solutions and going with whatever comes to mind first
21:23:35
jcowan
When I raised the idea of generic functions based on general (pure) predicates, he immediately raised the efficiency argument.
21:24:05
jcowan
In truth, people prefer and find intuitive, flexible, and efficient, what they are used to
21:24:10
p_l
as in, code that is too generic for the scope of the problem, causing increased complexity and thus loss of *human* performance in dealing with it
21:25:38
p_l
In general, my memory seems to recall mostly one somewhat common use case for defstruct in normal code (not implementation-code)
22:33:24
fiddlerwoaroof
It's a quick way of generating functions like point-x point-y when you're using vectors to represent data.
22:35:46
aeth
fiddlerwoaroof: I'd much rather generate them separately because in practice you don't want 2D, you want 2D, 3D, and 4D when talking about points
22:36:23
aeth
Well, a general purpose graphical program will wind up working with all 3 because of how the various APIs work.
22:36:26
fiddlerwoaroof
I'm generally not dealing with these sort of things in a context where it makes sense for me to go fully generally
22:37:14
fiddlerwoaroof
:type vector is a useful way to get better ways of accessing vectors than just (elt some-vector 4)
22:37:49
aeth
It's not as useful as it could be because it doesn't give you the type definition, which a regular defstruct gives you.
22:38:09
aeth
I use define-array-and-type instead: https://gitlab.com/zombie-raptor/zombie-raptor/blob/48a75d6b543950c3581e5f413be8bd5c4cf3a357/util/array.lisp#L58-71
22:39:21
fiddlerwoaroof
I don't write game engines, so the performance doesn't matter too much to me
22:40:24
aeth
A vector gives you a lot of options, e.g. I often find that it's most convenient to split them into multiple values.
22:41:02
fiddlerwoaroof
Anyways, my use case is mostly things like dealing with CSV of a predefined format
22:41:18
aeth
If you write your own representation, you basically force someone to handle it as a unique case with with-accessors even if it's not unique.
22:41:51
aeth
(which often involves just translating it into a vector, doubling memory usage and slowing everything down)
22:42:09
fiddlerwoaroof
See, the way I would handle that would be to define a protocol of generic functions that are specialized on both arrays and my classes
22:42:33
fiddlerwoaroof
And, if the user had other things thy wanted to use, they could define methods as necessary
22:43:07
aeth
You can't define a method that specializes on arrays of a certain length because that's something that's only in the type, not in the class.
22:44:52
aeth
Well, ctypecase/etypecase is how you do that sort of thing, but it will only work for functions/methods of one, or maybe two, arguments before it quickly becomes impractical.
22:44:54
fiddlerwoaroof
Anyways, I suspect that the subset of CL I use and care about is fairly different than yours :)
22:49:28
aeth
fiddlerwoaroof: Immutable vectors would actually be a good way to handle both use cases, assuming the compiler was smart enough to reuse the old "immutable" vector instead of copying where necessary (which would be very tricky, actually, because the compilers mostly work on functions as a unit). Then the vector could be generic and specific.
22:50:17
aeth
i.e. then you could just say (immutable-vector 1f0 2f0 3f0) and the implementation would make it a single-float vector since you can't store some other type in there.
22:50:30
aeth
If you say (vector 1f0 2f0 3f0) it has to be a T vector because you could do whatever you want to it afterward
22:53:39
slaterr
is there an immutable vector in standard CL or some popular third party library? and immutable collections in general
22:54:25
aeth
You'd probably want it to be done at the implementation level and handled with a portability library, like threads, if you wanted efficiency.
22:55:10
fiddlerwoaroof
Anyways, you could totally have (vector 2f0 3f0 4f0) return a specialized vector as long as you have a check on assignment
22:55:13
aeth
pjb: Incorrect. #(a b c) is a literal vector, where mutation is undefined and should not happen. However, it is not tagged as immutable, at least in SBCL, so once you cross the compilation-unit boundary it will be mutated, with undefined and undesirable results (i.e. if you set b to d, then it will be saved as d next time you start the program)
22:59:13
aeth
You can, however, safely treat #(a b c) and '(a b c) as immutable within a function, and should do so if that's what you want and it doesn't cross the function boundary. (compilation-unit/file is a bit trickier, but it could be safe there as well)
23:04:57
aeth
Tagging literals as immutable would be a nice implementation specific extension that could eventually solve the issue, though, afaik. It wouldn't look pretty but you *can* create them in functions, e.g. `#(a b ,c)
23:21:14
jcowan
I wouldn't count on the output of backquotes being immutable: they are code, not literals.
23:21:38
jcowan
(that is "count on" even in the sense that you might count on it in a Lisp system that makes literals immutable.)
23:40:32
Bike
well, it's immutable in that it's undefind to modify it. i guess a system could expand it into (IMMUTABLE-VECTOR 'a 'b c) or something so it's tagged even though it's constructed at runtime.
23:43:17
jcowan
Or adopt the Racket solution whereby default conses *are* immutable, and you have to ask for mutability explicitly. This was done fairly recently, and remarkably few programs had to be changed.
23:48:26
jcowan
http://blog.racket-lang.org/2007/11/getting-rid-of-set-car-and-set-cdr.html lists only four basic cases where people used the mutability of conses in practice: for alleged efficiency with nconc and nreverse, queues (easily replaced with explicit mutable pairs), alist updating (easily changed to a functional solution), and the use of conses as a handy 2-element struct.
23:49:13
jcowan
Of course from a standards perspective it can't be done, no matter how nice it would be. Racket's implementations of standard varities have mutable pairs.
0:29:35
pfdietz
If you wanted to create an immutable vector, then (eval v), or perhaps (eval (list 'quote v)), would do it. Perhaps one of the few good uses of eval.
0:31:17
Bike
i think if there were actual runtime-immutable structures it would probably be better to expose a function to make em
0:59:02
aeth
pfdietz: You don't need to eval, though. You can also write a macro to produce essentially the same result, which would be even more preferable.
1:00:56
aeth
Bike: You'd also want to expose the subtype because you'd need type declarations to actually allow the compiler to assume that they're immutable when you use something like car or aref. (Well, you could also just directly declare them, but that solution is messier than a type one.)