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
#lang racket/base | |
(require racket/function | |
racket/list | |
racket/dict) | |
(provide (struct-out lens) | |
lens-get | |
lens-mod | |
lens-set |
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
#lang racket/base | |
(require racket/control) | |
(struct monad (bind return) #:transparent) | |
(define-syntax-rule (with-monad ([val m]) body ...) | |
(let* ([m-once m] | |
[val | |
(lambda (ma) |
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
var demethodize = function(func) { | |
"use strict"; | |
return function(...args) { | |
func.apply(args[0], args.slice(1)) | |
}; | |
}; | |
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
fn mut_to_pure<'f, A, FI>(mut f: FI) -> Box<FnMut(A) -> A+'f> | |
where FI: FnMut(&mut A)+'f { | |
Box::new(move |mut a| {f(&mut a); a}) | |
} | |
fn pure_to_mut<'f, A, FI>(mut f: FI) -> Box<FnMut(&mut A)+'f> | |
where FI: FnMut(A) -> A+'f { | |
Box::new(move |a: &mut A| { | |
unsafe { | |
let mut temp: A = std::mem::uninitialized(); |
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
#![allow(dead_code)] | |
struct HNil; | |
struct HCons<H, T> { | |
head: H, | |
tail: T | |
} | |
trait Contains<A> { |
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
#![allow(dead_code)] | |
use std::fmt; | |
use std::error; | |
#[derive(Debug)] | |
enum SplitMutError { | |
AliasedMut | |
} |
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
pry(main)> Object.methods | |
C:/Ruby192/lib/ruby/gems/1.9.1/gems/pry-0.9.3-x86-mingw32/lib/pry/helpers/base_h | |
elpers.rb:92:in `block in simple_pager': undefined local variable or method `out | |
put' for Pry::Helpers::BaseHelpers:Module (NameError) | |
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/pry-0.9.3-x86-mingw32/lib/pry/h | |
elpers/base_helpers.rb:91:in `each' | |
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/pry-0.9.3-x86-mingw32/lib/pry/h | |
elpers/base_helpers.rb:91:in `each_slice' | |
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/pry-0.9.3-x86-mingw32/lib/pry/h | |
elpers/base_helpers.rb:91:in `simple_pager' |
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
Question Answer given Answer expected | |
Is your character an adult man? Probably not Probably | |
Has your character really existed? Probably not Probably | |
Does your character have legs? Probably not No | |
Does your character use a cane? Probably not No | |
Is your character on an album cover? Probably not No | |
Does your character wield electricity/lightning as a weapon? Probably not No | |
Does your character have claws? Probably not No | |
Is your character Muslim? Probably not No | |
Is your character hired to kill people? Probably not No |
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 delimonads.core | |
(:require [monads.core :as m]) | |
(:use delimc.core)) | |
(reset | |
(defn bind-cont | |
"Binds its monadic value argument to the continuation. | |
Easy to understand explanation: (f (bind-cont x) y) becomes do {x' <- x; f x' y}" | |
[monadic-value] |
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
#_(deftest maybe-plus | |
(is (= :bogus | |
@(m/plus [m/maybe-zero-val | |
(m/do m/maybe | |
[_ (m/maybe 1)] | |
(throw (Exception. "Should not be thrown")))])))) |
OlderNewer