Sha256: f666f3c4c47be6737c528525ab3ea4532b0b365b9adcfc338ca480e874bc8618

Contents?: true

Size: 1.03 KB

Versions: 272

Compression:

Stored size: 1.03 KB

Contents

module House

let subjects = 
    [("house that Jack built", "lay in");
     ("malt", "ate");
     ("rat", "killed");
     ("cat", "worried");
     ("dog", "tossed");
     ("cow with the crumpled horn", "milked");
     ("maiden all forlorn", "kissed");
     ("man all tattered and torn", "married");
     ("priest all shaven and shorn", "woke");
     ("rooster that crowed in the morn", "kept");
     ("farmer sowing his corn", "belonged to");
     ("horse and the hound and the horn", "")]

let numberOfBlocks = List.length subjects

let line number index = 
    let (subject, verb) = List.item (index - 1) subjects
    let ending = if index = 1 then "." else ""
    
    if index = number then "This is the " + subject + ending
    else "that " + verb + " the " + subject + ending
    
let block number = 
    let lineForBlock = line number
    [number .. -1 .. 1]
    |> List.map lineForBlock
    |> List.reduce (fun x y -> x + "\n" + y)    

let rhyme = 
    [1..numberOfBlocks]
    |> List.map block
    |> List.reduce (fun x y -> x + "\n\n" + y)

Version data entries

272 entries across 272 versions & 1 rubygems

Version Path
trackler-2.2.1.54 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.53 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.52 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.51 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.50 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.49 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.48 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.47 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.46 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.45 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.44 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.43 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.42 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.41 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.40 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.39 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.38 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.37 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.36 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.35 tracks/fsharp/exercises/house/Example.fs