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
set -g prefix ` | |
bind ` send-prefix | |
# Use vi or emacs-style key bindings in the status line, | |
# for example at the command prompt. The default is emacs, | |
# unless the VISUAL or EDITOR environment variables are set | |
# and contain the string `vi'. | |
set -g status-keys vi | |
set-option -g default-shell /opt/homebrew/bin/fish |
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 poll [] | |
(let [opts (atom {})] | |
(fn [& args] | |
(if (empty? args) | |
(when (seq @opts) | |
(print-table (for [[k v] (reverse (sort-by last @opts))] | |
{:name k :votes v}))) | |
(doseq [arg args | |
:when (or (string? arg) (keyword? arg)) | |
:let [arg (keyword arg)]] |
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
module FoldScan where | |
import Prelude hiding (foldl, foldl', foldl1, | |
foldr, foldr', foldr1, | |
scanl, scanl1, scanr, scanr1) | |
-- (map fn list) -> list | |
-- map is (1:1) with the original list and returns a copy of a list after applying a fn to each element |
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
-- module cis194.ch1 where | |
-- std | |
toDigits' :: Integer -> [Integer] | |
toDigits' = reverse . f | |
where | |
f 0 = [] | |
f x = (x `rem` 10) : f (x `div` 10) |
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 suffixes | |
"Recursive suffixes" | |
[xs] | |
(if-let [xs (seq xs)] | |
(cons xs (suffixes (rest xs))) | |
[()])) | |
(defn suffixes |
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
(* use "suffix.sml"; *) | |
(* input = output *) | |
(* [1,2,3] = [[1,2,3], [2,3], [3], []] *) | |
(* std recursion *) | |
fun suffixes ([]) = [[]] | |
| suffixes (xs) = xs :: suffixes (tl xs); |
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
(require '[clojure.string :as s]) | |
(defn bool->int | |
[bool] | |
(if bool 1 0)) | |
(defn single-char-days | |
"Translate two-char representation of certain day to one" | |
[days] | |
(-> days |
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
<?php | |
class F | |
{ | |
public static $fns = [ | |
'apply' => 'call_user_func_array', | |
'min' => 'min', | |
]; | |
public static function __callStatic($method, $args) |
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
/** | |
* A partial function applicator. | |
*/ | |
function partial() { | |
var fn = arguments[0]; | |
var slice = Array.prototype.slice; | |
var partialArgs = slice.call(arguments, 1); | |
return function () { | |
var args = slice.apply(arguments); | |
return fn.apply(null, partialArgs.concat(args)); |
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
(mapcat (fn [[k coll]] (map vector (repeat k) coll)) | |
[[:a [1 2]] [:b [3 4]]]) | |
=> '([:a 1] [:a 2] [:b 3] [:b 4]) |
NewerOlder