Skip to content

Instantly share code, notes, and snippets.

View yvern's full-sized avatar

Yuri Vendruscolo da Silveira yvern

  • Deutsche Bank
  • London, UK
  • 06:53 (UTC +01:00)
View GitHub Profile
@yvern
yvern / fun.red
Last active September 30, 2018 06:20
Functional constructs experiments in Red
->: make op! :function ; arrow-style lambdas: [x]->[x + 1]
id: ["Identity function, one in, same out" x]->[x]
;--------------------------------------------------------------------------------------
cmp: ["Gets a block! of words! or blcoks! that represent a function! and composes it in the usual way"
fs [any-block!]]->[ [x]-> compose/deep/only [take reduce append (reduce fs) [x] ]
]

Keybase proof

I hereby claim:

  • I am yvendruscolo on github.
  • I am yorggen (https://keybase.io/yorggen) on keybase.
  • I have a public key ASDqLdUfP3b0deCu7XZZ14NCNK9b3tz1reDa9vnZtJBCKgo

To claim this, I am signing this object:

@yvern
yvern / hello.sh
Created December 8, 2019 01:56
a varied, warm welcoming for your terminal
if [ -x /usr/games/cowsay -a -x /usr/games/fortune ]; then
fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1) | lolcat -a -d 1 --freq "0.$(shuf -i 1-10 -n 1)" --seed $RANDOM
fi
@yvern
yvern / keybase.md
Created June 15, 2020 20:36
keybase.md

Keybase proof

I hereby claim:

  • I am yvendruscolo on github.
  • I am yorggen (https://keybase.io/yorggen) on keybase.
  • I have a public key ASDJQ4AZlhKlr9FQlguETvKkODjY6Xox0-ShNaE9beqXrwo

To claim this, I am signing this object:

@yvern
yvern / dont.clj
Created January 20, 2023 18:44
Break clojure compilation
(defmacro dont
[& _]
(throw (ex-info "(╯°□°)╯︵ ┻━┻" {})))
(dont
(defn add [a b] (+ a b)))
(defmacro no-bangs!
[forms]
(if (->> forms
flatten
(filter symbol?)
(some (comp (partial re-find #"\!") name)))
(throw (ex-info "/(•̀o•́)ง No bangs!" {}))
forms))
(no-bangs!
(defrule overflow?
[?middle <- :middle]
[:or [?max <- :top] [?max <- :right]]
[:test (<= ($ ?max) ($ ?middle))]
=>
(insert! {:fact-type :overflow!}))
(defrule underflow?
[?middle <- :middle]
[:or [?min <- :bottom] [?min <- :left]]
(ns yvern.hard-rule
(:require [clara.rules :refer [defrule insert!]]))
(def $ (comp val first))
(defrule all-together
[?middle <- :middle]
[:or
[:and [?max <- :top] [?min <- :bottom]]
[:and [?min <- :left] [?max <- :right]]]
(defrule not-ok
[:a]
=>
(when (< 0.5 (rand))
(insert! {:fact-type :b})))
(ns yvern.defrule)
(def clara-inserts
"The forms we care about, capable of inserting facts."
#{'insert! 'insert-all!})
(def descend*
"Transducer to descend into inner forms, looping for those we care about, the ones that insert facts.
Unfortunately we can't really figure out if someone defines another function that calls `insert!`."
(comp (map macroexpand)