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 decorizzle(**outerkwargs): | |
def takekwarg(f): | |
def inner(*args, **kwargs): | |
kwargs.update(outerkwargs) | |
return f(*args, **kwargs) | |
return inner | |
return takekwarg | |
@decorizzle(foo="LOL") |
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 decorizzle(foo=None): | |
def takekwarg(f): | |
def inner(*args, **kwargs): | |
kwargs['foo'] = foo | |
if len(args): | |
return f(args[0], *args[1:], **kwargs) | |
return f(*args, **kwargs) | |
return inner | |
return takekwarg |
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 decorizzle(foo=None): | |
def takekwarg(f): | |
def inner(*args, **kwargs): | |
kwargs['foo'] = foo | |
return f(*args, **kwargs) | |
return inner | |
return takekwarg | |
@decorizzle(foo="LOL") |
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
package main | |
import ( | |
"bytes" | |
"encoding/binary" | |
"errors" | |
"fmt" | |
"io" | |
"io/ioutil" | |
) |
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
module type S = sig | |
type 'a t | |
val fold : 'a t -> init:'acc -> f:('acc -> 'a -> 'acc) -> 'acc | |
end | |
module MyFolder = struct | |
type 'a t = (int * 'a) list | |
let fold (a : 'a t) ~init ~f = | |
let rec aux prev = function |
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 recursive-reverse [coll] | |
(loop [ [x & xs] (seq coll) | |
acc '()] | |
(if (nil? x) | |
acc | |
(recur xs (cons x acc))))) |
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
open Core.Std | |
module T = Core.Time | |
module Message = struct | |
exception Invalid_message_format of string | |
type msg = { | |
channel : string |
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
open Core.Std | |
type json = | |
| String of string | |
| Int of int | |
| Float of float | |
| Bool of bool | |
| Array of json list | |
| Object of (string * json) |
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
open Core.Std | |
let maybe_list this that = | |
match this with | |
| Some l -> | |
(List.append l [that]); | |
| None -> [that] | |
let group_by f l = |
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
open Core.Std | |
let maybe_list this that = | |
match this with | |
| Some l -> | |
Some (List.append l [that]); | |
| None -> Some [that] | |
let group_by f l = |