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.1.0.37 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.36 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.34 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.33 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.32 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.31 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.30 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.29 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.28 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.27 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.26 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.25 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.24 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.23 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.22 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.21 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.20 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.19 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.18 tracks/fsharp/exercises/house/Example.fs
trackler-2.1.0.17 tracks/fsharp/exercises/house/Example.fs