freenode/#lisp - IRC Chatlog
Search
20:15:05
jmercouris
when I only want to use the second value that a function returns, is there a way to do that without using multiple-value-bind and (declare (ignore first-value)) ?
20:26:36
pfdietz
There should be a place whose effect is to discard the value assigned to it. (values), I guess but can that be used inside another (values ...)?
20:34:30
White_Flame
but yeah, the store would still occur, while the ideal would be to elide it altogether
20:36:58
White_Flame
yeah, have been trying that sort of thing as well. it seems to expand with a weird NIL injected
20:39:47
White_Flame
(setf (values (values)) 1) seems to be the shortest failure case I can construct
20:40:34
White_Flame
but (setf (values a (values)) (values 1 2)) shows the broken lambda parameters that get expanded
20:56:05
dim
ahah I just did my first implementation of anagrams-p using the prime number products trick, it's fun
21:35:45
alandipert
my day 3 AoC - thanks in advance for criticism. i consciously avoided loop and hash tables (until the end...) and flow was much improved https://github.com/alandipert/advent-of-code-2018/blob/master/day03.lisp
21:37:54
alandipert
one question i had was, is there an easy way to initialize a struct from a list of slot values?
21:39:24
alandipert
i didn't care to look but i imagine there's a way to get the list of matched groups from cl-pcre, and so i thought yeah - that function would be tigher if i applied that list to a constructor
21:40:16
Bike
if you do (defstruct (claim (:constructor make-claim (id x y width height))) ...) you should be able to call make-claim like (make-claim id x y width height)
21:45:02
Bike
i don't know if you can do that with ppcre, though, especially since you also need to parse stuff into integers.
21:45:03
tumdum
alandipert: your claim parsing is much nicer than mine: https://git.sr.ht/%7Ettt/aoc18/tree/master/day3.lisp ;)
21:50:25
_death
cool.. mine was made in a hurry and to the noise (music?) of a handyman hammering ceramics in my bathroom https://gist.github.com/death/fd93cf68c475a303c07a2ae5890439e9
21:56:00
eminhi
now this was noise. https://bpaste.net/show/dee55ad8acae . I only knew split-seq utility.
22:48:00
dim
tumdum: I'm trying to go CL only for now (until I'm bored), as an excuse to learn the standard better, https://github.com/dimitri/AdventOfCode/blob/master/2018/d03.lisp#L27
22:49:36
dim
_death: I used repeat instead of below in my loops so that I don't have to compute the end index ;-)
22:49:57
dim
(defun update-fabric-claims (fabric claim) (loop :for row :from (claim-top claim) :repeat (claim-height claim) :do (loop :for col :from (claim-left claim) :repeat (claim-width claim) :do (incf (gethash (cons row col) fabric 0)))))
22:51:57
no-defun-allowed
is there a case-lookalike that expands to a lookup table with O(1) access?
23:06:21
no-defun-allowed
my issue would be creating the table at compile time with the correct lexical scoping
23:39:37
aeth
e.g. (dotimes (i 4) (dotimes (j 5) (dotimes (k 6) (format t "~D~%" (+ i j k))))) vs. (loop :for i :from 0 :below 4 :do (loop :for j :from 0 :below 5 :do (loop :for k :from 0 :below 6 :do (format t "~D~%" (+ i j k)))))
23:41:38
aeth
And if you have a simple repeated iteration pattern in your code (probably 6 or so times for it to be worth it) that cannot be expressed concisely outside of loop but you can define either a do-foo macro or a higher order function using do/do*/dotimes/loop/map/mapcar/maphash/etc., you should do that imo rather than directly use loop in that case.
23:42:30
aeth
But if you're e.g. doing some numerical algorithm that involves stepping through 5+ different variables, using both :with and :for, with a lot of complex logic going on, then you probably should just use LOOP.
23:45:28
aeth
(You could also use DO or DO* for many of these complicated iterations, but then the first thing you'll hear from your peers is "I can't read this")
23:48:06
aeth
DO/DO* are great for macro targets, and they're basically just LET with a(n optional) step, a terminator, and a return value.
23:52:42
aeth
The three points of confusion are probably (1) the terminating condition is the opposite of what you might expect, (2) the terminating condition and the optional return value are in the same s-expression, and (3) a well-written DO often doesn't have a body at all.
23:54:45
aeth
With LOOP you can specify :until/:while, the return is pretty clearly marked, and the step (:for) vs. not-step (:while) forms are clearly distinguished instead of relying on an optional third element in a binding's list.
0:36:02
no-defun-allowed
depends on the context, i think DO would be better for looping, but it does expand to TAGBODY in the end
0:36:33
aeth
eminhi: In most implementations DO will macroexpand to block over let over tagbody and DO* will macroexpand to block over let* over tagbody, e.g. it's pretty straightforward in SBCL with this: (macroexpand-1 `(do ((x 42) (y 1 (1+ y))) ((> y x) (+ y x)) (format t "~D ~D~%" x y)))
0:37:12
aeth
(It actually has two TAGBODYs in SBCL's macroexpansion of DO because DO-FOO forms have an implicit TAGBODY so you can write your own labels/GOs in there for more complicated iterations.)
0:39:29
eminhi
I want to reason with something more abstract than TAGBODY. and I really dont want to target loop.
0:39:32
aeth
eminhi: If what you want is ultimately BLOCK over LET over TAGBODY over TAGBODY then DO (or DO* for LET*) can save a lot of lines in your macro
0:40:13
aeth
If you want something more complicated (e.g. MULTIPLE-VALUE-BIND) then you'd have to work with TAGBODY directly, or you'd have to work with someone else's more advanced macro.
0:56:44
PuercoPop
How would you phrase the relationship between the method and the specialized parameter? e.j. "The EMACS-INSPECT method that specializes in HASH-TABLE"?
0:58:28
PuercoPop
Also can someone with access to SLIME check if inspecting the resulting hash-table from the following expression breaks for them?
0:58:29
PuercoPop
(let ((ht (make-hash-table))) (setf (gethash #C(0 1) ht) t (gethash #C(0 2) ht) t) ht)
0:59:56
PuercoPop
Basically the problem is that it applies < to complex numbers, that only applies to reals
1:00:56
PuercoPop
I'm going to recommend to change the typep to real. However I'm wondering it would make sense to implement an ad-hoc order
1:03:12
aeth
PuercoPop: Distance from 0 (assuming it's on the real-imaginary plane) with the real part as a tie breaker could be another way to sort complex.
1:12:25
aeth
There's probably a way to combine ABS and PHASE so it gets the regular sorting order on reals as well, e.g. (phase 1) is 0.0 and (phase -1) is pi
1:12:25
PuercoPop
aeth: I've opened the issue on the SLIME issue tracker but the fix only for Sly, maybe you can send a PR that orders numbers that way?
1:15:22
drmeister
Given a quicklisp system - is there a way to get the dependency graph before quicklisp starts compiling stuff?
1:16:02
aeth
hmm... Backwards sort of PHASE's angle and then ABS would work for complex in a way that also works on reals. i.e. if PHASE is the same, tiebreak with abs (since it's float you wouldn't be able to use =, though).
1:18:24
aeth
(obviously it's faster to have a typecase and only do this for complex, but you could still encounter things like #C(1d0 0d0) and #C(-1d0 0d0))
1:23:44
aeth
PuercoPop: Maybe something like this but without = (since you can't really use = on floats)? Sorts by angle then magnitude in a way that behaves like < if the imagpart is 0. (defun complex-< (x y) (if (= (phase x) (phase y)) (< (abs x) (abs y)) (> (phase x) (phase y))))
1:24:09
aeth
There's probably a name for something like this because sorting complex is not a new problem.
1:26:03
Bike
it's pretty easy to prove there's no total order, and that's about where things usually end
1:29:39
aeth
Bike: This seems like a weaker issue, though: can we produce a function that works with #'sort?
1:37:51
Xach
drmeister: .asd files are loaded and can run arbitrary lisp code, including loading and building other things. also :defsystem-depends-on is a problem.
1:38:41
Xach
drmeister: then you can look at the relationships between systems without much trouble.
1:39:08
Xach
drmeister: also, quicklisp precompiles info about those relationships, so if every system is from quicklisp, you can query quicklisp's indexes instead of asdf's.
1:43:40
Xach
drmeister: with quicklisp, i compile and load everything, and record what actually gets loaded, and use that to find the de facto relationships.
1:45:53
drmeister
We have the clasp build down to about 30 min by forking every compile-file that we can.
1:46:11
drmeister
Then we build the Cando quicklisp systems and it drops back to serial mode and takes an hour - ugh.
1:47:05
drmeister
I'm thinking that I should load everything with quickload and then determine the system dependencies once everything is loaded and save the dependency graph to use the next time we build.
1:48:21
drmeister
POIU would be nice - but it's broken. A faster compiler would be nice - but... llvm.
1:50:18
aeth
drmeister: The problem with compiling systems in parallel is that some systems change globals as part of their compilation process, even though they probably shouldn't do that and should leave that to the user (except for pushing to *FEATURES* and a few other niche cases)
1:54:44
drmeister
If I quickload systems from the leaves in to the root in separate forks it will compile all of the source code once and then I can quickload the root and it will hopefully all work.
1:55:58
drmeister
I'm going to change compile-file so that it compile-files into a temporary file and then atomically renames it to the target.
1:56:00
pfdietz
The advantage of compiling things in parallel is you can fail when people do that (which is wrong, as what happens when you reload precompiled fasls into a new image?)
2:02:42
pfdietz
If you've already compiled a system, you can just load the fasls, right? So if the compile process caused some side effect that you're depending on, you won't get that just by loading the fasls.
2:17:41
pfdietz
In general, any global change that you depend on should go into an eval-when that causes it to be performed when the fasl is loaded as well.
2:18:41
drmeister
I'm looking at asdf-viz - it visualizes these things but I can't make hide nor hair of it.
2:30:06
no-defun-allowed
dot's a program for spitting out SVGs from edges of a graph, so half the program would probably just be flattening the tree of dependencies
5:22:57
rk[ghost]
it returns icky, in values.. i forget.. how to grab first part of a values return?
5:30:02
rk[ghost]
pillton: thanks much. that saved me grepping thru a bunch of files to see how i used it in a project (who knows which one, long enough ago) :P
6:03:31
elderK
I've switched clients - it may have been a long long time ago. I didn't check the timestmap :P
6:04:03
equwal
I can't remember. I have a vague memory, probably I was talking about how in emacs you can get a library to rotate the in-frame windows.
6:33:00
elderK
Like, do they just use destructuring-bind and let it do checking, or do they first verify the structure /then/ call destructuring-bind