Skip to content

Instantly share code, notes, and snippets.

View wavebeem's full-sized avatar

Sage Fennel Mock wavebeem

View GitHub Profile
// author: Brian Mock <mock.brian@gmail.com>
#include <stdio.h>
typedef unsigned int uint;
double clamp(double, double, double);
uint pack_rgb(uint, uint, uint);
uint shade_color(uint, double);
void unpack_rgb(uint, uint*, uint*, uint*);
update_interval 1
#out_to_x no
out_to_console yes
temperature_unit fahrenheit
#temperature_unit celsius
TEXT
${uptime_short}\
::: ${mem}\
::: ${mixer}%${if_mixer_mute} (M)${endif}\
module Test where
data Range
= FromTo Integer Integer
deriving (Eq, Ord)
instance Show Range where
show (FromTo x y) = show x ++ " --> " ++ show y
x --> y
# vim: syn=sh:
#
# Sleep before doing a command
SleepDo() {
local time="$1"
shift
sleep "$time"
eval "$@"
}
a [] = 0
a (x:xs) = x + a xs
b xs = b' 0 xs
where
b' a [] = 0
b' a (x:xs) = b' (a+x) xs
c xs = foldl (+) 0 xs
@wavebeem
wavebeem / sum.hs
Created January 20, 2011 07:39
3 different sum functions in Haskell
module Sum where
a [] = 0
a (x:xs) = x + a xs
b xs = b' 0 xs
where
b' q [] = q
b' q (x:xs) = b' (q + x) xs
@wavebeem
wavebeem / list.hs
Created January 20, 2011 02:58
Haskell list
module List where
data List a
= Null
| Node (List a) a
deriving (Show, Eq)
build = build' Null
where
build' Null [] = Null
@wavebeem
wavebeem / bst.hs
Created January 20, 2011 02:58
Haskell binary search tree
module BST where
-- Define the BST data type
data BST a
= Node (BST a) (BST a) a
| Tip
deriving (Show, Eq)
-- Make a leaf node
leaf y = Node Tip Tip y
@wavebeem
wavebeem / gist:784115
Created January 18, 2011 08:04
list.hs
module List where
data List a
= Null
| Node (List a) a
deriving (Show, Eq)
build = build' Null
where
build' Null [] = Null
module Main where
-- Define the BST data type
data BST a = Node (BST a) (BST a) a
| Tip
deriving (Show, Eq)
-- Make a leaf node
leaf y = Node Tip Tip y