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 System | |
open MonoTouch.UIKit | |
open Cirrious.FluentLayouts.Touch | |
type PhotoViewController() = | |
inherit UIViewController() | |
let imageViewSize = 200.0f | |
let imageView = | |
let view = UIImageView( |
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
Device.OnPlatform <| function | |
| iOS, Tablet -> | |
this.Padding <- Thickness(0, 0, 0, 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
type Writer<'Result, 'Output> = | |
| W of 'Result * seq<'Output> | |
type WriterBuilder() = | |
member this.Zero() = W ((), Seq.empty) | |
member this.Yield(x) = W (x, Seq.empty) | |
member this.Return(x) = this.Yield(x) | |
member this.Bind(W (a, xs), k) = | |
let (W (b, ys)) = k a | |
W (b, Seq.append xs ys) |
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 Trello | |
( BoardId() | |
, Credentials() | |
, Trello() | |
, runTrello | |
, Board() | |
, getBoard | |
) where | |
import Data.Maybe |
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 ExpressM a = forall e. Eff (express :: Express | e) a | |
data HandlerM a = HandlerM (Request -> Response -> ExpressM Unit -> ExpressM a) | |
instance monadEffHandlerM :: MonadEff eff HandlerM where | |
liftEff act = HandlerM \_ _ _ -> unsafeInterleaveEff act |
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 ShootOutAnimator(referenceView: UIView) = | |
let speed = 1300.0f | |
let animator = UIDynamicAnimator(referenceView) | |
... | |
member this.ShootOut(view: UIView, direction: Direction) = | |
let x, y = direction.UnitVector | |
let shoot = UIDynamicItemBehavior(view, AngularResistance=2.0f) | |
shoot.AddLinearVelocityForItem(PointF(x * speed, y * speed), view) | |
shoot.AddAngularVelocityForItem(x * 3.0f, view) | |
shoot.Action <- fun () -> |
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. |
OlderNewer