Skip to content

Instantly share code, notes, and snippets.

View refaktor's full-sized avatar

Refaktor refaktor

View GitHub Profile
(ns clojpression-puzzle
(:require [clojure.test :refer [is]]))
(def compress (partial transduce (comp (partition-by identity)
(mapcat (fn [[c & _ :as cs]]
[(count cs) c])))
str))
(defn run [& _]
(is (= (compress "AAABBAAC") "3A2B2A1C")))
@refaktor
refaktor / hofs.rye.red
Last active February 14, 2022 16:33
HOFs test
;
; # Rye HOFs demo
;
numbers: { 1 2 3 4 }
;
; map
;
numbers |map { + 100 } |prn ; add 100 to all numbers
numbers |map { .factor-of 2 } |prn ; turn to 1 if even and 0 otherwise
numbers |map { :x , x * x } |prn ; run to it's squares
@refaktor
refaktor / rpn_calculator.rye
Last active March 21, 2024 08:09
Improved RPN Calculator in Rye, original made by Capital-EX
; This is improved example of *RPN calculator* originally made CapitalEx from Discord/Concatenative
; https://gist.github.com/Capital-EX/d08a37765ef898cd432f662ffc7aaf98
rye .needs { fyne }
do\in fyne {
append-a: fn { n } { value-a .get-text .concat n |set-text* value-a }
num-button: fn { n } { button n [ 'append-a n ] }
calc-button: fn { lbl op1 } {