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 System (system) | |
import System.Posix (sleep) | |
import Text.Printf (printf) | |
import Flickr.Monad | |
import Flickr.Types | |
import Flickr.Photos | |
import Flickr.URLs (photoSourceURL) | |
import Flickr.Groups.Pools (getPhotos) |
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
# Lists is an array of sorted lists (arrays): | |
# [ [...], [...], … ] | |
def ListMerge(Lists): | |
# The number of elements awaiting merge in each list. | |
sizes = [len(L) for L in Lists] | |
# Create a heap with a slot for each list. | |
heap = range(len(Lists)) | |
for i in heap: | |
# Heap elements are (key, value) pairs of (element, List index) | |
heap[i] = (Lists[i][0], i) |
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
- (NSArray*)mergeSortArrayUsingSelector:(SEL)comparator | |
{ | |
id buf[[self count]]; | |
[self getObjects:buf]; | |
mergesort_(buf, [self count], comparator); | |
return [NSArray arrayWithObjects:buf count:[self count]]; | |
} |
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
void mergesort_(id* objs, size_t count, SEL cmp) | |
{ | |
// Base case. | |
if (count < 2) return; | |
size_t left_count = count / 2; | |
size_t right_count = count – left_count; | |
id left_objs[left_count]; | |
id right_objs[right_count]; | |
// Function pointer for comparison IMP. |
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
data Tree a = Branch (Tree a) (Tree a) | |
| Leaf a | |
treeOp :: (a -> b) -> (b -> b -> b) -> Tree a -> b | |
treeOp fL fB (Leaf a) = fL a | |
treeop fL fB (Branch t1 t2) = treeOp fL fB t1 `fB` treeOp fL fB t2 | |
myFringe :: Tree a -> [a] | |
myFringe = treeOp (:[]) (++) |
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 | |
# Install dependencies | |
sudo apt-get install ghc6 ghc6-prof ghc6-doc haddock libglut-dev happy alex \ | |
libedit-dev zlib1g-dev checkinstall | |
# Get haskell-platform | |
wget http://hackage.haskell.org/platform/2009.2.0.2/haskell-platform-2009.2.0.2.tar.gz | |
tar -xzf haskell-platform-2009.2.0.2.tar.gz | |
cd haskell-platform-2009.2.0.2 |
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
using System; | |
namespace Data | |
{ | |
public struct Maybe<T> where T : class | |
{ | |
public static implicit operator Maybe<T> (T value) | |
{ |
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
== Solution: <name of solution> == | |
=== Description === | |
# Briefly describe the solution. | |
=== Advantages === | |
# List advantages of the solution. | |
=== Disadvantages === | |
# List at least one disadvantage of the solution. |
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
module YataWindow ( YataWindow | |
, new, showAll | |
, onMessagePost | |
, displayTweets | |
) | |
where | |
import Control.Applicative | |
import Text.Printf (printf) |
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/runhaskell | |
import Data.List (isInfixOf) | |
import Web.Twitter (getUserTimeline) | |
import Web.Twitter.Monad (runTM) | |
import Web.Twitter.Fetch (nullAuthUser) | |
import Web.Twitter.Types (Status (..)) | |
username = "jonobacon" | |
patterns = ["rock", "awesome", "jam"] |
OlderNewer