Find it here: https://github.com/bitemyapp/learnhaskell
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
# I glanced through the pycket paper, saw few rules there. Ended up to doing this. | |
class Var(object): | |
def __init__(self, name): | |
self.name = name | |
def __repr__(self): | |
return self.name | |
class Lam(object): |
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
""" | |
This implements a fairly simple expression language via a Pratt-style parser. | |
The language supports fairly standard floating point literals, such as: | |
5 | |
1.09 | |
.16 | |
12e7 |
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
type re = C of char | Nil | Seq of re * re | Bot | Alt of re * re | Star of re | |
let rec null = function | |
| C _ | Bot -> false | |
| Nil | Star _ -> true | |
| Alt(r1, r2) -> null r1 || null r2 | |
| Seq(r1, r2) -> null r1 && null r2 | |
module R = Set.Make(struct type t = re let compare = compare end) | |
let rmap f rs = R.fold (fun r -> R.add (f r)) rs R.empty |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 | |
""" | |
Search longest common substrings using generalized suffix trees built with Ukkonen's algorithm | |
Author: Ilya Stepanov <code at ilyastepanov.com> | |
(c) 2013 | |
""" |
I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).
In Vim I have key bindings C-h/j/k/l
set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W
.) I'd like to use the same keystrokes for switching tmux panes.
An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\
.
Here's how it should work:
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
-- An implementation of Peter Landin's SECD machine, as described in | |
-- "The Mechanical Evaluate of Expressions" | |
import Prelude hiding (lookup) | |
type Name = String | |
data Expr a = ID Name | |
| Obj a | |
| Fun Name (Expr a) | |
| Apply (Expr a) (Expr a) |
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
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks | |
# of the ActiveRecord pattern. Several apps I have seen, and several | |
# developers I have spoken to are looking towards other patterns for object | |
# persistence. The major drawback with ActiveRecord is that the notion | |
# of the domain object is conflated with what it means to store/retrieve | |
# it in any given format (like sql, json, key/value, etc). | |
# | |
# This is an attempt to codify the Repository pattern in a way that would | |
# feel comfortable to beginner and seasoned Ruby developers alike. | |
# |
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 Main where | |
First, import all the needed modules. | |
> import Text.Parsec hiding (State) | |
> import Text.Parsec.Indent | |
> import Control.Monad.State | |
Next, define our new Parser type. This replaces the Identity monad | |
with the (State SourcePos) monad. |
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
// as NSObject | |
RKObjectMapping* mapping = [RKObjectMapping mappingForClass:[TestMappable class]]; | |
[mapping mapKeyPath:@"numbers" toAttribute:@"orderedSet"]; | |
TestMappable* object = [[[TestMappable alloc] init] autorelease]; | |
id<RKParser> parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:@"application/json"]; | |
id data = [parser objectFromString:@"{\"numbers\":[1, 2, 3]}" error:nil]; | |
RKObjectMappingOperation* operation = [[RKObjectMappingOperation alloc] initWithSourceObject:data destinationObject:object mapping:mapping]; | |
BOOL success = [operation performMapping:nil]; |