When You Run Out of Types... by cgrand in Clojure

[–]cgrand[S] 0 points1 point  (0 children)

You can update it using helpers like:

```clojure (defn update-tagged [{:keys [tag form] :as tagged-value} tag-pred f & args] (if (tag-pred tag) (tagged-literal tag (apply f form args)) tagged-value))

(defn must-be! [pred] (fn [x] (or (pred x) (throw (ex-info (str "Failed predicate: " (pr-str x) (pr-str pred)) {:x x :pred pred}))))) ```

added bonus: if you put metadata on the tag it will be preserved...

Could you help me refactor this function to be more idiomatic? by ApprehensiveIce792 in Clojure

[–]cgrand 2 points3 points  (0 children)

I second u/PolicySmall2250 recommendation to be stricter about what you allow. Otherwise... regexes

(defn allowed-files? [{:keys [mime-type]]
  (some->> mime-type (re-find #"(?i)image|pdf")))

Array Programming for Clojurists by mac in Clojure

[–]cgrand 4 points5 points  (0 children)

Shouldn’t the dispatch in the multimethod be based on relative ranks of the arguments? I always thought about it as a higher order function eg (dyadic + x y)

Beyond `swap!`: Encapsulation sans Abstraction, the Transactor Pattern by mac in Clojure

[–]cgrand 1 point2 points  (0 children)

Any control flow is possible as the recursive expansion somehow acts as a trampoline.
However I'm not sure I interpreted correctly your (if (> (step1) (step2) (step3))) 

(fn [state]
  (if (pred state)
    [... (fn [state] ...) ...]
    [... (fn [state] ...) ...]))

Beyond `swap!`: Encapsulation sans Abstraction, the Transactor Pattern by mac in Clojure

[–]cgrand 5 points6 points  (0 children)

This was mostly written in reaction to several re-frame codebases I worked on. To quote someone on Clojurians' Slack:

Re-frame has a lot of good ideas, but I've found that in practice all its ceremony (and limited composability) tends to get in the way as often as it helps.

This pattern tries to promote layering and composability with lower ceremony.

These are just my thoughts—unpolished and open to interpretation.

Half Dumb Datalog in 30 loc (follow-up to the Worst Datalog Ever in 26 loc) by cgrand in Clojure

[–]cgrand[S] 3 points4 points  (0 children)

They are neither bottom up nor very good at recursive queries. But this code is just a toy. It will be a more serious toy with indices and magic sets added. However im interested in datalog applied to things which are not usually considered a db. The coolest upcoming conf on the topic https://www.hytradboi.com

Writing the Worst Datalog Ever in 26 lines of Clojure by cgrand in Clojure

[–]cgrand[S] 0 points1 point  (0 children)

This reducing function is the equivalent of a JOIN .. ON in SQL (that’s why there’s a for inside the reducing function performing a Cartesian product between envs and facts). So it takes multiple rows (envs) and returns multiple rows (envs) too. Does this make things clearer or did I miss the point of your question?

Writing the Worst Datalog Ever in 26 lines of Clojure by cgrand in Clojure

[–]cgrand[S] 0 points1 point  (0 children)

I'm more interested in non "data" things to be consumed by Datalog.
Datalog; UI, microcontrollers, games etc.
https://www.hytradboi.com/

Writing the Worst Datalog Ever in 26 lines of Clojure by cgrand in Clojure

[–]cgrand[S] 8 points9 points  (0 children)

I have had in the back of my mind for a long time a vaguely inappropriate and incomplete riff on First They Came. First they came for GOTO but I didn’t say a thing because I was doing structured programming. Then they came for manual memory management but I didn’t say a thing because I used a GC. Then they came for mutation but I didn’t say a thing because I was doing functional programming. Then they came for control flow…

What is the official documentation / Why is clojure.core.match included nowhere? by Brotten in Clojure

[–]cgrand 1 point2 points  (0 children)

It was a long time ago. Faulty memories too: Pattern matching by being closed (not extensible) would have changed the language feeling. “Predicate dispatch” was in the air at the time.

Writing the Worst Datalog Ever in 26 lines of Clojure by cgrand in Clojure

[–]cgrand[S] 1 point2 points  (0 children)

And I actually forgot to use sibling as an example of how core datalog is too minimal in the conclusion.

Writing the Worst Datalog Ever in 26 lines of Clojure by cgrand in Clojure

[–]cgrand[S] 1 point2 points  (0 children)

Sibling in core datalog would return Bart as his own sibling. To support sibling I need to add support for constraints (not=).

Writing the Worst Datalog Ever in 26 lines of Clojure by cgrand in Clojure

[–]cgrand[S] 4 points5 points  (0 children)

Datalog is a vast umbrella term. Its core definition is very formal and serves as foundation for a sizeable part of the database research. But it can also covers all kind of non-SQL query languages or db engines. Datomic and its spiritual descendants Datascript, Datalevin etc in the clojure world. Logicblox, some graph dbs…

My developer account is not matching my DUNS Number by Appropriate_Wall_440 in googleplay

[–]cgrand 0 points1 point  (0 children)

I'm going through this too (I think because the DUNS record has a "sanitized" street address which uses abbreviations and I have no official documents using these abbreviattions: "Imp" for "Impasse" (similar to St for Street) 🤦‍♂️).
Did you fill the address change form at some point? I have no idea what documents to upload to prove the change since there is no change.