From b9359b65a37229079e9209a3f05aa25ee4db8f35 Mon Sep 17 00:00:00 2001 From: Ummon Date: Tue, 28 Apr 2015 16:17:41 +0200 Subject: [PATCH] Cleaning. --- .../Assignment_07-FSharp/Program.fs | 17 ++-- Assignment_07/Assignment_07.iws | 89 +++++++++++++------ 2 files changed, 67 insertions(+), 39 deletions(-) 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 @@ - - + + + + + + + + + + + + + + + + + + -- 2.43.0