This file contains hidden or 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 cursive.llm.api.malli-repro | |
(:require [clojure.data.json :as json] | |
[clojure.string :as str] | |
[malli.core :as m] | |
[malli.transform :as mt])) | |
(defn decode-type | |
"This is required for decoding :type fields, otherwise they are not | |
converted and don't dispatch properly." | |
[x] |
This file contains hidden or 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 test.core | |
(:import [clojure.lang IDeref])) | |
(require '[lazymap.core :as lm]) | |
(defn lazy-assoc-in | |
"Value should be either derefable (delay or future) which will be dereffed when value is needed | |
or a function which will be called." | |
[m [k & ks] f] | |
(if (seq ks) |
This file contains hidden or 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
app.filter('bytes', function() { | |
return function(bytes, precision) { | |
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-'; | |
if (typeof precision === 'undefined') precision = 1; | |
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB']; | |
var number = Math.floor(Math.log(bytes) / Math.log(1024)); | |
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number]; | |
}; | |
}); |
This file contains hidden or 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
(defn debounce | |
"Creates a channel which will change put a new value to the output channel | |
after timeout has passed. Each value change resets the timeout. If value | |
changes more frequently only the latest value is put out. | |
When input channel closes, the output channel is closed." | |
[in ms] | |
(let [out (chan)] | |
(go-loop [last-val nil] | |
(let [val (if (nil? last-val) (<! in) last-val) |
This file contains hidden or 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
(defn outrun-2 [pyramid] | |
(->> pyramid | |
(reduce | |
(fn [previous line] | |
(mapv (fn [this i] | |
(let [left (get previous (dec i) 0) | |
right (get previous i 0)] | |
(+ this (max left right)))) | |
line | |
(range)))) |
This file contains hidden or 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
(defn mrg [[x & xrest :as X] [y & yrest :as Y] R] | |
(if (and X Y) | |
(if (<= x y) | |
(recur xrest Y (conj R x)) | |
(recur X yrest (conj R y))) | |
(concat R X Y))) | |
(defn mrgsrt [X] | |
(if (> (count X) 1) | |
(let [[left right] (split-at (/ (count X) 2) X)] |