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
defmodule WadlerLindig do | |
# Elixir implementation of the Wadler document algebra as described in | |
# "Strictly Pretty" (2000) by Christian Lindig | |
# http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2200 | |
# | |
# The original Haskell implementation of the algorithm relies on lazy | |
# evaluation to unfold document groups on two alternatives: | |
# _flat_ (breaks as spaces) and _broken_ (breakes as newlines). | |
# Implementing the same logic on a strict language such as Elixir leads | |
# to an exponential growth of the possible documents, unless document |
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
defmodule BenchmarkInspect do | |
def big_string do | |
s = trunc(:random.uniform * 400) + 1 | |
String.duplicate "x", s | |
end | |
def rand_struct do | |
a = [ | |
fn(x) -> { x, 1, 2 } end, | |
fn(x) -> { big_string, x, 2 } end, |
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
FUNCTION CALLS % TIME [uS / CALLS] | |
-------- ----- --- ---- [----------] | |
'Elixir.Wadler':group/1 5 0.00 0 [ 0.00] | |
'Elixir.Binary.Inspect.Utils':'-group_maybe/2-fun-0-'/1 1 0.00 0 [ 0.00] | |
'Elixir.Wadler':glue/2 27 0.00 1 [ 0.04] | |
gen:call/4 1 0.00 1 [ 1.00] | |
gen:do_call/4 1 0.00 1 [ 1.00] | |
gen_server:call/3 1 0.00 1 [ 1.00] | |
'Elixir.Binary.Inspect.Utils':'-group_maybe/3-fun-0-'/1 4 0.00 1 [ 0.25] | |
code:ensure_loaded/1 9 0.01 2 [ 0.22] |
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
#!/bin/bash | |
GPI="plot.gpi" | |
echo "set terminal svg size 480,320 fname 'Gill Sans' fsize 8 rounded dashed | |
# set background | |
set object 1 rect from screen 0, 0, 0 to screen 1, 1, 0 behind | |
set object 1 rect fc rgb 'white' fillstyle solid 1.0 | |
# Line style for axes | |
set style line 80 lt 0 |
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
#!/usr/bin/env python | |
# encoding: utf8 | |
from unicodedata import normalize | |
from string import ascii_letters | |
from random import randint | |
# Miller-Rabin probabilistic primality test (HAC 4.24) | |
# returns True if n is a prime number | |
# n is the number to be tested | |
# t is the security parameter |
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
#!/usr/bin/env python | |
# encoding: utf8 | |
# HAC 3.61: generates x_{i+1}, a_{i+1} and b_{i+1} | |
# from a, b and c, partitioning the field | |
def step_xab(x, a, b, alpha, beta, n, Z): | |
s = x % 3 | |
# S1 | |
if s == 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
defmodule WadlerLindig do | |
@moduledoc """ | |
Pretty printing library inspired by Philip Wadler. | |
Custom pretty printers can be implemented using | |
functions, exported from this module. | |
Elixir implementation of the Wadler document algebra as described in | |
"Strictly Pretty" (2000) by Christian Lindig | |
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2200 |
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
defmodule Memoize do | |
alias Memoize.ResultTable | |
defmacro defmem(header, do: body) do | |
{ name, _meta, vars } = header | |
quote do | |
def unquote(header) do | |
case ResultTable.get(unquote(name), unquote(vars)) do | |
{ :hit, result } -> |
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 kepler-bouwkamp.core | |
(:use quil.core)) | |
(def tau 6.283185307179586) | |
(defn circle [cx cy r] | |
"Draws a circle centered at (cx, cy) with radius r." | |
(let | |
[d (* r 2)] | |
(ellipse cx cy d d))) |
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
#import "cocos2d.h" | |
@interface BezierCurveNode : CCNode | |
@property (nonatomic) CGPoint origin; | |
@property (nonatomic) CGPoint cp1; | |
@property (nonatomic) CGPoint cp2; | |
@property (nonatomic) CGPoint destination; | |
@property (nonatomic) ccColor3B color; |
OlderNewer