Fork me on GitHub
#clojure
<
2018-12-25
>
jaide01:12:07

(case 'notes 'notes "notes found" 'other-thing "other thing")

jaide01:12:47

That throws an error for me about there being a duplicate case. What should I do to achieve that?

tomjack01:12:30

user> (case 'quote 'foo 42)
42
user> (= '(case 'quote 'foo 42) '(case 'quote (quote foo) 42))
true

tomjack01:12:56

user> (case 'notes notes "notes found" other-thing "other thing")
"notes found"

jaide03:12:21

OH wow for some reason I wasn’t expecting it to be that simple. Thanks!

noprompt04:12:17

case doesn’t evaluate the left sides of it’s clauses.

abdullahibra07:12:25

i have a stupid question over this code, is there a way in clojure to know the syntax tree of z which is (+ x y) ?

emccue14:12:24

In the way you defined it, no. (+ x y) evaluates to z and unless you re-read the source code there is no way

emccue14:12:50

You can use macros to have that info though (give me a moment to work up an example

emccue14:12:52

So one example, if you want the original form to have the definition as metadata

emccue14:12:15

You can also use the :file metadata along with the line and col info to read your own source and extract it out

manutter5116:12:52

It does not let you take a compiled function and extract the syntax tree from it, but it does have some tools that are somewhat related to the topic, so maybe some interesting stuff to explore there.

emccue14:12:55

I'm trying to puzzle out core.logic

emccue14:12:03

is there a way to "not" a goal?

norman14:12:56

You can fail if a goal is true

emccue14:12:50

this is what i have so far

emccue14:12:14

I want to be able to express that a loves b, but b does not love a

emccue14:12:26

I think i kinda understand what you are saying now \

emccue14:12:40

but i dont understand why i need all those applys

emccue14:12:12

(or better phrased, what exactly the goals take in as args)

norman15:12:15

this probably belongs in #core-logic

norman15:12:17

(run* [q] (membero q [1 2 3]) (conda [(== q 2) fail] [succeed]))

norman15:12:39

That’s the ugly pattern to fail if a goal is true

norman15:12:48

(defmacro noto [goal] `(conda [~goal fail] [succeed]))

norman15:12:25

If you need to do this, it’s probably not a good thing 🙂

rutledgepaulv22:12:44

This talk kind of blew my mind this weekend: https://www.youtube.com/watch?v=ZgqFlowyfTA . I’d love to have a fully reactive system from database to user with efficient incremental computation everywhere. I’d like to understand the internals of declarative dataflow a bit better.. does anyone know where I can find plain implementations of the core algorithms (preferably in clojure and without the distributed system / networking stuff 😬)?

Dustin Getz13:12:18

I believe it is implemented in Rust

rutledgepaulv17:12:37

Thanks for the link and doing that interview!

❤️ 4
rutledgepaulv01:12:46

Maybe I was expecting these incremental processors to be something more fundamental and composing like a transducer and they’re actually just lots of hand tuned mutation code?

ncg14:12:26

Differential Dataflow's raison d'être is to generalize incremental computation to work in a distributed setting. The two fundamental algorithms are progress tracking (implemented in Timely dataflow) and the logic of partially ordered times. Any incremental computation requires a previous state to make use of. In a distributed setting, determining the previous state to use is a hard problem, which Differential solves for you. This is almost a separate issue from how you express incremental computations themselves. Differential comes with a bunch of incrementalized operators built-in (hand tuned mutation code, if you will), which happen to be great for many common use cases (Datalog evaluation being one of them). But there are other ways of expressing incremental computations, which could all be made to work with Differential, e.g: http://www.umut-acar.org/self-adjusting-computation https://www.youtube.com/watch?v=R3xX37RGJKE

ncg14:12:26

FWIW I too am interested in simplified implementations of the core concepts for educational purposes, but I probably won't have the time to work on them anytime soon.

rutledgepaulv17:12:39

Thanks Nikolas - this information is super helpful. I’ll be digging into all this for a while I think 🙂

ncg20:12:33

Feel free to send me a mail at any point!

😀 4