This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; main.rye ... you can start this with rye -console . when in the same directory | |
music: context { | |
list: fn { "retrieves and lists soma.fm streams" } { | |
get https://soma.fm | |
|reader | |
|parse-html { <a> [ .attr? 'href |collect! ] } ; NOTE: collect / collected is a temp idea, don't like it that much but it solves some cases | |
pop-collected! | |
|filter { .is-match* regexp "^\/[a-z]+\.pls$" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; this is the result of save\current after (in) the asciinema demo: | |
; Building & using simple utils in Rye console https://asciinema.org/a/684031 | |
; There are 2 bugs in current save\current that got exposed with this code and we will fix | |
; * -> is saved in primary form which is |_-> which caused loader error | |
; * [ ] blocks just recently became distinct from { }, we need to update the code to separate them too | |
hn: context { | |
hn: https://hacker-news.firebaseio.com/v0/ | |
get-top: fn { n } { hn ._+ "topstories.json" |get |parse-json |head n |map { .to-integer } } | |
get-titles: fn { ids } { |map { .embed hn ._+ "item/{}.json" |get |parse-json -> "title" } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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 } { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; | |
; # 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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"))) |