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
(defn maybe-comp | |
"Composes functions, maybe :). The returned fn returns nil if anyone does so." | |
([f] f) | |
([f g] | |
(fn | |
([] (when-let [a (g)] | |
(f a))) | |
([x & args] (when-let [a (apply g x args)] | |
(f a))))) | |
([f g & fs] |
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
(defmacro with-read-lines [reader bindings & body] | |
(cond | |
(= (count bindings) 0) `(do ~@body) | |
(symbol? (bindings 0)) `(let* [rdr# (~reader ~(bindings 1)) | |
~(bindings 0) (line-seq rdr#)] | |
(try | |
(with-read-lines ~reader ~(subvec bindings 2) ~@body) | |
(finally | |
(. rdr# close)))) | |
:else (throw (IllegalArgumentException. |
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 micro-tools.excel | |
(:require [dk.ative.docjure.spreadsheet :as spreadsheet]) | |
(:import [org.apache.poi.xssf.usermodel XSSFWorkbook XSSFSheet] | |
[java.lang String])) | |
(defrecord TableInfo [mapping sheet-name]) | |
(defmulti table (fn [info obj] (class obj))) | |
(defmethod table XSSFSheet [info sheet] | |
(->> sheet |
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
(use gauche.lazy) | |
(use gauche.collection) | |
(use util.match) | |
(use math.prime) | |
; bit | |
(define << ash) | |
(define & logand) | |
(define lor logior) | |
(define xor logxor) |
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
(require '[clojure.java.io :as io]) | |
(import '[java.io IOException]) | |
(def base-folder (slurp "scripts/file_size_checker.input.txt")) | |
(def output-file "scripts/file_size_checker.output.txt") | |
(defn large-files [folder] | |
(sort-by #(.length %) > | |
(->> folder | |
file-seq |
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
def input_loop(question, quit): | |
while not quit(ans := input(question)): | |
yield ans | |
for ans in input_loop("Yo? >>", lambda x: x == "quit"): | |
print("Your input: ", ans) | |
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
import operator as ope | |
from functools import partial | |
lt, le, eq, ne, ge, gt = [(lambda x: partial(o, x)) for o in [ope.lt, ope.le, ope.eq, ope.ne, ope.ge, ope.gt]] | |
test = [f for f in [lt(1), le(1), eq(1), ne(1), ge(1), gt(1)]] | |
print(*test, sep="\n") |
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
; input | |
(define (my-read) | |
(let ([a (read)]) | |
(if (symbol? a) | |
(symbol->string a) | |
a))) | |
(define (my-read-line) | |
(let ([line (read-line)]) | |
(if (string=? "" line) | |
(my-read-line) |
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
protocol Potato { | |
func hash() -> Int | |
} | |
extension Potato where Self: Hashable { | |
func hash() -> Int { | |
return self.hashValue | |
} | |
} |
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
enum Val { | |
case int(Int) | |
case bool(Bool) | |
case symbol(String) | |
} | |
enum Ope { | |
case add | |
case mul | |
case lt |
OlderNewer