projects
/
Scala.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleaning.
[Scala.git]
/
Assignment_07-FSharp
/
Assignment_07-FSharp
/
Program.fs
diff --git
a/Assignment_07-FSharp/Assignment_07-FSharp/Program.fs
b/Assignment_07-FSharp/Assignment_07-FSharp/Program.fs
index
601ecdb
..
2a768cd
100644
(file)
--- 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<Bar> = (Empty.Push <| Bar ()).Push <| Bar ()
assert (b.Top = 3)
let c : Stack<Bar> = (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 ()
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 () =
// Question 4.
let question4 () =
- let rec
primesS
ieve sequence =
+ let rec
s
ieve sequence =
seq {
let h = Seq.head sequence
yield h
seq {
let h = Seq.head sequence
yield h
- yield!
primesS
ieve <| Seq.filter (fun m -> m % h <> 0) sequence
+ yield!
s
ieve <| Seq.filter (fun m -> m % h <> 0) sequence
}
}
- let primes =
primesS
ieve <| (Seq.initInfinite id |> Seq.skip 2)
+ let primes =
s
ieve <| (Seq.initInfinite id |> Seq.skip 2)
printfn "first primes: %A" <| (Seq.take 100 primes |> Seq.toList)
[<EntryPoint>]
printfn "first primes: %A" <| (Seq.take 100 primes |> Seq.toList)
[<EntryPoint>]