Sha256: 204423242699855bc7505307e2cb83b940e7a793cc45329f1d12552c94966c39

Contents?: true

Size: 1 KB

Versions: 65

Compression:

Stored size: 1 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 verse number = 
    let lineForBlock = line number
    [number .. -1 .. 1]
    |> List.map lineForBlock

let recite startVerse endVerse = 
    [startVerse..endVerse]
    |> List.map verse
    |> List.reduce (fun x y -> x @ "" :: y)

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
trackler-2.2.1.128 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.127 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.126 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.125 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.124 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.123 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.122 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.121 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.120 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.119 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.118 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.117 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.116 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.115 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.114 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.113 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.111 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.110 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.109 tracks/fsharp/exercises/house/Example.fs
trackler-2.2.1.108 tracks/fsharp/exercises/house/Example.fs