Skip to content

Instantly share code, notes, and snippets.

View nulldatamap's full-sized avatar

Nulldata nulldatamap

View GitHub Profile
data Free f a = Free (f (Free f a)) | Pure a
deriving Functor
liftF :: Functor f => f a -> Free f a
liftF action = Free (fmap Pure action)
data Ex x = Ex x (Maybe x)
deriving Functor
┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬─────────┐
│~ │! ⌶ │@ ⍫ │# ⍒ │$ ⍋ │% ⌽ │∧ ⍉ │& ⊖ │* ⍟ │( ⍱ │) ⍲ │_ ! │+ ⌹ │Backspace│
│` ⋄ │1 ¨ │2 ¯ │3 < │4 ≤ │5 = │6 ≥ │7 > │8 ≠ │9 ∨ │0 ∧ │- × │= ÷ │ │
├────┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬──────┤
│Tab │Q │W │E ⍷ │R │T ⍨ │Y │U │I ⍸ │O ⍥ │P ⍣ │{ ⍞ │} ⍬ │| ⊣ │
│ │q ? │w ⍵ │e ∊ │r ⍴ │t ~ │y ↑ │u ↓ │i ⍳ │o ○ │p * │[ ← │] → │\ ⊢ │
├───────┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴──────┤
│Caps │A │S │D │F │G │H │J ⍤ │K ⌸ │L ⌷ │: ≡ │" ≢ │Enter │
│Lock │a ⍺ │s ⌈ │d ⌊ │f _ │g ∇ │h ∆ │j ∘ │k ' │l ⎕ │; ⍎ │' ⍕ │ │
├────────┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──────────┤
-- Naïve indenter
space = repeat ' '
_indent :: Int -> [Int] -> [Char] -> [Char]
_indent _ _ [] = ""
_indent w k@(t:_) (',':s) = '\n' : take t space ++ ',' : _indent (t+1) k s
_indent w k (c:s) = c : _indent (w+1) (f c) s
where
f v
use std::str::Chars;
use std::io::IoError;
use std::io::fs::File;
use std::iter::Peekable;
use std::error::{FromError, Error};
struct Settings {
clips : Vec<(String, Path)>,
}
impl MarketData {
pub fn collect( &mut self, data : ( Count, Money, Count ) ) {
let ( assets, price, holders ) = data;
self.day_count += 1;
self.asset_history.push( assets );
self.price_history.push( price );
self.holders_history.push( holders );
}
impl MarketData {
pub fn collect( &mut self, market : &mut Market ) {
self.day_count += 1;
self.asset_history.push( market.assets );
self.price_history.push( market.price );
self.holders_history.push( market.holders );
}
#![feature(asm)]
extern crate time;
use std::rand::random;
use std::char::from_u32;
use time::precise_time_ns;
type Chunk = [char, ..5];
(ns world.gen)
(defn rrange [mn mx]
(+ (* (rand)
(- mx mn))
mn))
(defn printmatrix [matrix]
(print(reduce str(for [x matrix] (str (reduce str(for [y x] (if (= y nil)0 1))) "\n")))) matrix)
// Actor::update( &mut self, &Vec<Box<Actor>> )
pub fn update( &mut self ) {
for i in range( 0u, self.actors.len() ) {
let actor = self.actors.get_mut( i );
actor.update( &self.actors );
}
}
import Data.Bits
import Data.Char
import Data.Word
_intToHex :: Int -> Int -> Bool -> String
-- i: integer, l: length of the number string, s: show sign?
_intToHex i l s = sign ++ body
where
n = if i < 0
then if s