These are chat archives for got-lambda/expression

8th
Dec 2017
Jean-Louis Giordano
@Jell
Dec 08 2017 07:06
since we're making it a workshop I've limited the number of sits, I'll expend if we figure out a way to setup more stations / tables
Jean-Louis Giordano
@Jell
Dec 08 2017 13:23
Day 7 of AoC is really challenging for me, I'm finding it quite hard
Erik Svedäng
@eriksvedang
Dec 08 2017 13:25
haven't looked today..!
oh, yesterday
Jean-Louis Giordano
@Jell
Dec 08 2017 13:25
yeah yesterday's
I managed the 1st part OK, but I'm still struggling with part 2
Erik Svedäng
@eriksvedang
Dec 08 2017 13:27
OK, haven't tried the first one so don't know what's coming :)
jolod
@jolod
Dec 08 2017 13:33
For part 1, you don't know if the triple (name, weight, children) is correct. The triple weight and the children could belong to two other names?
(Strike the second triple.)
Jean-Louis Giordano
@Jell
Dec 08 2017 13:36
oh boy finally solved it in the most inelegant way possible :p
not following what you're saying @jolod ?
jolod
@jolod
Dec 08 2017 13:37
I don't know if I'm reading the problem right.
Erik Svedäng
@eriksvedang
Dec 08 2017 13:37
you tricked me into starting to solve this, damnit!
Jean-Louis Giordano
@Jell
Dec 08 2017 13:38
sorry :p I'm bothering everyone lately
jolod
@jolod
Dec 08 2017 13:38
Each line contain three facts. But none of them might belong together. Right?
(Writing on the phone. Suboptimal.)
Jean-Louis Giordano
@Jell
Dec 08 2017 13:39
each line is a node in the tree, with name (weight) -> children
Lars Brinkhoff
@larsbrinkhoff
Dec 08 2017 13:45
Reddit is asking, are there any Carp users?
Erik Svedäng
@eriksvedang
Dec 08 2017 13:55
what does "user" mean? ^^
probably not, by most definitions...!
Lars Brinkhoff
@larsbrinkhoff
Dec 08 2017 13:59
I guess, people using Carp to make applications. Maybe libraries, tools, etc.
Original question is in /r/Lisp.
Erik Svedäng
@eriksvedang
Dec 08 2017 14:13
ok, then the answer is no
Veit Heller
@hellerve
Dec 08 2017 14:14
hey!
i identify as a user!
so, one
Erik Svedäng
@eriksvedang
Dec 08 2017 14:14
true :)
the question should be "is there a Carp user?"
jolod
@jolod
Dec 08 2017 14:25
@Jell But the info is assumed to be incorrect.
Incorrectly grouped into triples, I mean.
Like, you have a list of names, a list of weights, and a list of lists of children and you should pair (triple 🙂) them up so that it is balanced. No?
Jean-Louis Giordano
@Jell
Dec 08 2017 14:29
for part 1 the weights are irrelevant
oh! yeah I see how your solution makes... a lot more sense @eriksvedang
Erik Svedäng
@eriksvedang
Dec 08 2017 14:44
hehe ok :) can we see yours? I'll do the next part later, I hope
Part 1 is tolerable, Part 2 is like... nightmarish
I have some ideas on how to rewrite it (in particular in Haskell)
it's not my proudest work :p
jolod
@jolod
Dec 08 2017 15:05
@Jell I'm still super confused. So the description about you not being sure if the info is just text fill and an excuse to ask which the bottom program is.
Now I realized t he source of my confusion.
"you're not sure which program gave which information". You don't know their names, you can like point at them or whatever and ask the programs questions. Like spatially.
I assumed the problem was to infer the tree structure and that there was only one structure that made sense.
I guess I just wanted an excuse to use core.logic... ;-)
Jean-Louis Giordano
@Jell
Dec 08 2017 15:08
:) I was considering core.logic:ing it out after my Haskell attempt
jolod
@jolod
Dec 08 2017 15:08
Still talking about part 1?
Jean-Louis Giordano
@Jell
Dec 08 2017 15:09
yeah for part 1
jolod
@jolod
Dec 08 2017 15:10
I guess I can't say what my solution-not-yet-written is, due to spoiling?
Jean-Louis Giordano
@Jell
Dec 08 2017 15:10
:D
sorry perhaps I have spoiled it a bit removing relevant comments
jolod
@jolod
Dec 08 2017 15:11
I'll PM.
jolod
@jolod
Dec 08 2017 15:19
It was nice to do it in Clojure.
jolod
@jolod
Dec 08 2017 16:00
Updated my gist that I posted above. Not pasting it again because gitter will show my solution.
Jean-Louis Giordano
@Jell
Dec 08 2017 16:48
that was neat!
jolod
@jolod
Dec 08 2017 17:11
@Jell Should I post part 2 as well? Honestly I'd like you to try it so that it works on your input.
My bad disc was just above the root disc.
Jean-Louis Giordano
@Jell
Dec 08 2017 17:11
shoot!
jolod
@jolod
Dec 08 2017 17:11
OK, hold on and I'll add it to the gist.
Jean-Louis Giordano
@Jell
Dec 08 2017 17:12
:thumbsup:
jolod
@jolod
Dec 08 2017 17:14
Done.
@Jell Updated find-odd-disc.
Jean-Louis Giordano
@Jell
Dec 08 2017 17:18
yep that works!
jolod
@jolod
Dec 08 2017 17:19
Clojure's lack of TCO scared me into using loop/recur for some reason. Rewrote using iterate.
@magthe I wrote a recursive function! :-D
@Jell Works. But is it readable though? :-)
Jean-Louis Giordano
@Jell
Dec 08 2017 17:24
my Friday fry-brain is too tired to answer that question :p
jolod
@jolod
Dec 08 2017 17:28
Then be happy I didn't write child-parent using ->>:
(defn child->parent [tower]
  (->> [child parent] 
    (for [[parent {:keys [children]}] tower
          child children])
    (into {})))
Just kidding. I wouldn't do that. It's just evil.
Jean-Louis Giordano
@Jell
Dec 08 2017 17:29
omg
I can't unsee this
that's really evil :p
jolod
@jolod
Dec 08 2017 17:33
(defn factorial [n] (->> n dec factorial (* n) (if (> 1 n) 1)))
Unsee that!
No wait.
(->> n dec factorial (* n) (if (> 1 n) 1) (defn factorial [n]))
Better.
Jean-Louis Giordano
@Jell
Dec 08 2017 17:36
something has broken inside me
there is no god
jolod
@jolod
Dec 08 2017 17:42
Isn't there a macro in emacs that can do this for you?
Jean-Louis Giordano
@Jell
Dec 08 2017 17:42
yeah with cider
I think?
you can toggle between the two forms
jolod
@jolod
Dec 08 2017 17:43
Does it stop you from doing the transformation above on factorial? (Or child->parent as well, actually.)
(Could've had the defn at the end there as well.)
Jean-Louis Giordano
@Jell
Dec 08 2017 17:44
haven't tried, you wrap / unwrap an expression so if you're pointing at defn probably unleashes hell like above
jolod
@jolod
Dec 08 2017 17:45
I think everyone agrees that things that introduce bindings really should not be threaded. :-)
Jean-Louis Giordano
@Jell
Dec 08 2017 17:45
I sure hope so :p