Skip to content

Instantly share code, notes, and snippets.

@Bost
Bost / utils.cljc
Created July 31, 2017 15:54
clojure: various utils
(defn in?
"true if seq contains elm"
[seq elm]
(boolean (some (fn [e] (= elm e)) seq)))
@Bost
Bost / for-loop.fish
Created August 16, 2017 13:07
fish: for-loop
function for-loop
set list \
"foo" \
"bar" \
"zee"
for item in $list
echo "item: $item"
end
end
@Bost
Bost / do_exec.py
Last active August 22, 2017 15:39
python: execute os command
#!/usr/bin/env python
from subprocess import Popen, PIPE
import operator
import os
import re
import datetime
import time
from functools import reduce
from pathlib import Path
(require '[clojure.core.async :as a])
(def xform (comp (map inc)
(filter even?)
(dedupe)
(flatmap range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
(flatmap flatten)
(random-sample 1.0)
;; Programming Languages, Homework 5
#lang racket
(provide (all-defined-out)) ;; so we can put tests in a second file
;; definition of structures for MUPL programs - Do NOT change
(struct var (string) #:transparent) ;; a variable, e.g., (var "foo")
(struct int (num) #:transparent) ;; a constant number, e.g., (int 17)
(struct add (e1 e2) #:transparent) ;; add two expressions
(struct ifgreater (e1 e2 e3 e4) #:transparent) ;; if e1 > e2 then e3 else e4