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
-- tree.hs | |
module Main where | |
import Graphics.Rendering.Cairo | |
import Canvas | |
import System.Random | |
main = do | |
gen <- getStdGen | |
let ns = randoms gen :: [Double] | |
canvas (draw ns) 600 600 |
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
(* | |
Compile by doing | |
fscp10.exe -r Mono.Cairo.dll -I /usr/lib/mono/gtk-sharp-2.0/ -r gtk-sharp.dll \ | |
-r gdk-sharp.dll -r glib-sharp.dll simpleclock.fs | |
*) | |
open System | |
open Gtk | |
open Cairo | |
let withDo g f v cr = f v cr; g cr |
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 Prelude | |
type 'a accum = Acc of 'a | Done of 'a | |
let optMap f x = match x with None -> None | Some y -> Some (f y) | |
let string_of_char c = String.make 1 c | |
let (^.) s c = s ^ string_of_char c | |
module Stream = |
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
#include <math.h> | |
#include <pango/pangocairo.h> | |
#define FONT "Sans" | |
static void | |
draw_text (cairo_t *cr) | |
{ | |
PangoLayout *layout; |
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
type ('a, 'b) types = | |
| Int of int | |
| Float of float | |
| String of string | |
| Option of 'a option | |
| Array of 'a array | |
| List of 'a list | |
| Function of ('a -> 'b) | |
module type GENERATOR = |
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
#include <stdio.h> | |
#include <string.h> | |
#include <alloca.h> | |
#include <sys/types.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
typedef int (*comparer)(const void *, const void *); | |
#define THREAD_THRESHOLD 8192 |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#define TEST_SIZE 10000000 | |
long arr[TEST_SIZE]; | |
void usage (char *name) | |
{ | |
printf("USAGE: %s [forward|reverse|both]", name); |
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
let base_default_alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
let base ?(alphabet=base_default_alphabet) n i = | |
let rec aux a n sg i l = | |
if i == 0 | |
then | |
let l = if l = [] && n > 0 then [a.[0]] else l in | |
let len = List.length l + if sg < 0 then 1 else 0 in | |
let s = String.create len in | |
if sg < 0 then s.[0] <- '-'; | |
let () = ignore (List.fold_right (fun i c -> s.[c-1] <- i; c-1) l len) in |
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
type 'a range_atom = | |
RChar of 'a | |
| RRange of 'a * 'a | |
and 'a range = 'a range_atom list | |
type 'a regex_atom = | |
Sub of 'a regex | |
| Or of 'a regex * 'a regex | |
| Char of 'a | |
| Opt of 'a regex_atom |
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
#let fac_loop n = | |
# let s = ref 1 in | |
# for i=2 to n do s := !s * i done; | |
# !s | |
camlFoo__fac_loop_58: | |
.L104: | |
movq %rax, %rsi | |
movq $3, %rax | |
movq $5, %rbx |