From: Ummon Date: Tue, 28 Apr 2015 14:17:41 +0000 (+0200) Subject: Cleaning. X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=Scala.git Cleaning. --- diff --git a/Assignment_07-FSharp/Assignment_07-FSharp/Program.fs b/Assignment_07-FSharp/Assignment_07-FSharp/Program.fs index 601ecdb..2a768cd 100644 --- a/Assignment_07-FSharp/Assignment_07-FSharp/Program.fs +++ b/Assignment_07-FSharp/Assignment_07-FSharp/Program.fs @@ -32,26 +32,21 @@ let question1 () = assert (b.Top = 3) let c : Stack = (Empty.Push <| Bar ()).Push <| Bar () - printfn "%A" <| - match c.Top with - | :? Bar -> true - | _ -> false + c.Top :> Bar |> ignore + c.Top :> Foo |> ignore let d : Stack<#Foo> = (Empty.Push <| Bar ()).Push <| Bar () - printfn "%A" <| - match d.Top with - | :? Bar -> true - | _ -> false + d.Top :> Bar |> ignore // Question 4. let question4 () = - let rec primesSieve sequence = + let rec sieve sequence = seq { let h = Seq.head sequence yield h - yield! primesSieve <| Seq.filter (fun m -> m % h <> 0) sequence + yield! sieve <| Seq.filter (fun m -> m % h <> 0) sequence } - let primes = primesSieve <| (Seq.initInfinite id |> Seq.skip 2) + let primes = sieve <| (Seq.initInfinite id |> Seq.skip 2) printfn "first primes: %A" <| (Seq.take 100 primes |> Seq.toList) [] diff --git a/Assignment_07/Assignment_07.iws b/Assignment_07/Assignment_07.iws index 3ef6b47..1e86121 100644 --- a/Assignment_07/Assignment_07.iws +++ b/Assignment_07/Assignment_07.iws @@ -28,8 +28,8 @@ - - + + @@ -53,8 +53,8 @@ @@ -80,6 +80,8 @@ + + @@ -158,8 +160,6 @@ - - @@ -176,6 +176,7 @@ + @@ -343,6 +344,12 @@ + + + + + true + @@ -415,43 +422,53 @@ 1430127821037 - - + - + - - - - - - - - - - - + + + + + + + + + - - - + + - + - + + + + + + + + @@ -466,8 +483,24 @@ - - + + + + + + + + + + + + + + + + + +