Sunday, October 25, 2009
Ninite - bulk installer, potentially useful
http://ninite.com/
Tuesday, September 29, 2009
F# running on the iPhone
I tried F# on the iPhone (via MonoTouch) tonight. The trivial hello-world code seemed to work just fine. I used standalone to build the (trivial) fsharp code:
type Foo() =
do System.Console.WriteLine("This output brought to you by the note F#");
mono ../FSharp-1.9.6.16/bin/fsc.exe -a Foo.fs
And added a line to instantiate a Foo in FinishedLaunching().
Loaded the resulting dll into MonoDevelop, along with FSharp.Core.dll, and it just worked. Or at least it worked in the simulator, haven't tried the real device yet.
Friday, September 18, 2009
Sequence of positions in a sequence (F#)
Steve Horsfield's blog had a post on fold functions that cared about the beginning, middle and ends of the sequence they were operating on. I think there’s a preprocessing step that simplifies the problem – transform the sequence into a seq<Position<'t>>, where Position tells you if the object is at the beginning, middle, or end of the sequence:
type Position<'t> =
| Beginning of 't
| Middle of 't
| End of 't
| Only of 't
let rec sequenceOfPositionsWithLazyList(existing: LazyList<'t>) =
seq {
let rec elementsAfterBeginning(s) =
seq {
match s with
| LazyList.Cons(h, LazyList.Nil) -> yield End(h); ()
| LazyList.Cons(h, t) -> yield Middle(h); yield! elementsAfterBeginning(t)
| _ -> ()
}
match existing with
| LazyList.Cons(h, LazyList.Nil) -> yield Only(h); ()
| LazyList.Cons(h, t) -> yield Beginning(h); yield! elementsAfterBeginning(t)
| LazyList.Nil -> ()
}
let sequenceOfPositions(existing: seq<'t>) = sequenceOfPositionsWithLazyList(LazyList.of_seq existing)
printfn "%A" (sequenceOfPositions [1;2;3])
printfn "%A" (sequenceOfPositions [1;3])
printfn "%A" (sequenceOfPositions [1])
printfn "%A" (sequenceOfPositions [])
The output is:
seq [Beginning 1; Middle 2; End 3]
seq [Beginning 1; End 3]
seq [Only 1]
seq []
I think that makes following steps much easier to write.
Friday, July 10, 2009
error: 'GDataInputStreamLogger' undeclared (first use in this function)
/Users/jamesmoore/dev/mba/gdata170/Source/Networking/GDataHTTPFetcherLogging.m: In function '-[GDataHTTPFetcher(GDataHTTPFetcherLogging) logCapturePostStream]': /Users/jamesmoore/dev/mba/gdata170/Source/Networking/GDataHTTPFetcherLogging.m:797: error: 'GDataInputStreamLogger' undeclared (first use in this function) /Users/jamesmoore/dev/mba/gdata170/Source/Networking/GDataHTTPFetcherLogging.m:797: error: (Each undeclared identifier is reported only once /Users/jamesmoore/dev/mba/gdata170/Source/Networking/GDataHTTPFetcherLogging.m:797: error: for each function it appears in.) /Users/jamesmoore/dev/mba/gdata170/Source/Networking/GDataHTTPFetcherLogging.m:800: error: expected expression before ')' token /Users/jamesmoore/dev/mba/gdata170/Source/Networking/GDataHTTPFetcherLogging.m:804: error: expected expression before ')' token
Set this preprocessor macro: STRIP_GDATA_FETCH_LOGGING=0.
(TBD: An actual explanation. Unfortunately, it's not high on my priority list right now.)
Monday, June 15, 2009
Merging two sequences in F# using LazyList
The problem is to merge two arrays into a third array in O(n) time. I like the F# solution using sequences and pattern matching - it feels like a nice way to write this sort of thing.
type MergeWithLazyLists() = static member merge(f, x: LazyList<'t>, y: LazyList<'t>) = seq { match x, y with | LazyList.Cons(xh, xt), LazyList.Cons(yh, yt) when f xh yh -> yield xh yield! MergeWithLazyLists.merge(f, xt, y) | LazyList.Cons(xh, xt), LazyList.Cons(yh, yt) -> yield yh yield! MergeWithLazyLists.merge(f, x, yt) | LazyList.Nil, LazyList.Cons(_, _) -> yield! y | LazyList.Cons(_, _), LazyList.Nil -> yield! x | LazyList.Nil, LazyList.Nil -> () } [<OverloadID("with sequences")>] static member merge(f, x: seq<'t>, y: seq<'t>) = MergeWithLazyLists.merge(f, (LazyList.of_seq x), (LazyList.of_seq y)) let result = MergeWithLazyLists.merge((fun x y -> x < y), (seq {2..6}), (seq {1..7..15})) printfn "%A" (Seq.to_array result) // [|1; 2; 3; 4; 5; 6; 8; 15|]
(A sequence in F# is anything that implements IEnumerable<'t>, so arrays and lists both work just fine.)
Wednesday, May 27, 2009
Recovering Linux RAID drives
I found TestDisk through this article: Mounting Linux drive images
