i just learned about clojure.tools.macro
, in particular symbol-macrolet
. I have an urge to overuse the heck out of this. a tasteful example: https://github.com/swannodette/logic-tutorial/blob/master/src/logic_tutorial/tut3.clj#L16
I didn't get that example. What is it doing, what is lvar?
Lvar is a logical variable which is unbound. It can unify to anything.
What's unify?
Why doesn’t (let [_ (lvar)] …)
work in this case?
it doesn't because then they are all the same lvar. but rather than write (== [(lvar) (lvar) [(lvar) (lvar) 'milk (lvar) (lvar)] (lvar) (lvar)] hs)
he made a macro that the form _
expands to (lvar)
(macroexpand
'(macro/symbol-macrolet [_ (lvar)]
(all
(== [_ _ [_ _ 'milk _ _] _ _] hs)
(firsto hs ['norwegian _ _ _ _])
(nexto ['norwegian _ _ _ _] [_ _ _ _ 'blue] hs)
(righto [_ _ _ _ 'ivory] [_ _ _ _ 'green] hs)
(membero ['englishman _ _ _ 'red] hs)
(membero [_ 'kools _ _ 'yellow] hs)
(membero ['spaniard _ _ 'dog _] hs)
(membero [_ _ 'coffee _ 'green] hs)
(membero ['ukrainian _ 'tea _ _] hs)
(membero [_ 'lucky-strikes 'oj _ _] hs)
(membero ['japanese 'parliaments _ _ _] hs)
(membero [_ 'oldgolds _ 'snails _] hs)
(nexto [_ _ _ 'horse _] [_ 'kools _ _ _] hs)
(nexto [_ _ _ 'fox _] [_ 'chesterfields _ _ _] hs))))
(do
(all
(==
[(lvar) (lvar) [(lvar) (lvar) 'milk (lvar) (lvar)] (lvar) (lvar)]
hs)
(firsto hs ['norwegian (lvar) (lvar) (lvar) (lvar)])
(nexto
['norwegian (lvar) (lvar) (lvar) (lvar)]
[(lvar) (lvar) (lvar) (lvar) 'blue]
hs)
(righto
[(lvar) (lvar) (lvar) (lvar) 'ivory]
[(lvar) (lvar) (lvar) (lvar) 'green]
hs)
(membero ['englishman (lvar) (lvar) (lvar) 'red] hs)
(membero [(lvar) 'kools (lvar) (lvar) 'yellow] hs)
(membero ['spaniard (lvar) (lvar) 'dog (lvar)] hs)
(membero [(lvar) (lvar) 'coffee (lvar) 'green] hs)
(membero ['ukrainian (lvar) 'tea (lvar) (lvar)] hs)
(membero [(lvar) 'lucky-strikes 'oj (lvar) (lvar)] hs)
(membero ['japanese 'parliaments (lvar) (lvar) (lvar)] hs)
(membero [(lvar) 'oldgolds (lvar) 'snails (lvar)] hs)
(nexto
[(lvar) (lvar) (lvar) 'horse (lvar)]
[(lvar) 'kools (lvar) (lvar) (lvar)]
hs)
(nexto
[(lvar) (lvar) (lvar) 'fox (lvar)]
[(lvar) 'chesterfields (lvar) (lvar) (lvar)]
hs)))
Aaaah, makes sense
@posobin unify means to unify the meaning of a logical variable. (unify (A 3) (2 3))
would unify the logical variable A with 2. I made up the signature of unify
here but that's the general idea
the real question is, are they any customer looking for that features: code quality in their IOT.....
I'm not sure you're fan about uncle bob there, but I was really struck by his proposal in one you tube video to go to the build of a corporation of development. Like doctors, lawyers have. His position, was close to yours @noisesmith: with the time, software will be everywhere. The day when a dramatic event will occur, with too much people dying because of software, there will be two possibilities: either developpers will have created that corporation, it will be reinforced, either lawyers will add a lot of regulatory constraints to them.
I have 2 screens on our customers system that are meant to show the same data, they don't. It doesn't match up all the time. I asked what I thought was a simple question, "which one is wrong?". "Don't know". Ok, I'll rephrase, for the current settings... What is the correct vlaues that should be shown? "Don't know." ".... Do you see my problem?" "It needs fixed." "Yes, it does, but how am I supposed to fix it if I don't know what the values to be displayed actually are or what one is wrong (they could be both be wrong)." "It needs fixed."
and the SQL behind both of them is wildly different, and both equally impenetrable.
A problem well defined is a problem half solved. Henri Poincarré. It seems you're not there !
When the work request is “I don’t know what I want,” then “I don’t know how to do that” is a valid implementation.
I want to scribble that all over the people I work withs faces with permanent marker
I know that feeling.
it's my day to day
one step deeper @qmstuart, I have guys matching your description AND not agreeing with my solution.
There seems to be a DRY violation. Two separate things (SQL queries) represent the same knowledge.
Sometimes you can tackle the problem by disentangling and the original intent (and bug) becomes clear.
In your case it seems you need to do that. So take it as a fun puzzle 😂
... but DID YOU FIX IT? 😄
If by fix, you mean I went and made a cheese toastie, then yes.
Hi there, this is considered spam for a few reasons: • wrong channel • no obvious links with Clojure
wait, so it was an on-topic post? 😆
It's interesting that posts in #off-topic have to be in a way on-topic.
I smell a Monty Python skit
breaking news: clojure
isn't a superset of edn
:
'1
is a valid symbol
in edn
But in clojure it is (quote 1)
'
is a valid symbol in EDN, also '1
whereas in Clojure this is expanded into the special form (quote 1)
not sure if it's intended that symbols can start with a quote in EDN though
of course (symbol "'1")
works
also 'foo/'1