Skip to content

Commit

Permalink
Regenerate all examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dungpa committed Apr 24, 2013
1 parent d59939e commit 8c0b065
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 34 deletions.
6 changes: 2 additions & 4 deletions tests/languageshootout_output/binarytrees.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ and [<Struct>] Tree(next : Next, item : int) =
let rec make item depth =
if depth > 0
then
Tree
(
{ Left = make (2 * item - 1) (depth - 1);
Right = make (2 * item) (depth - 1) }, item)
Tree({ Left = make (2 * item - 1) (depth - 1)
Right = make (2 * item) (depth - 1) }, item)
else Tree(defaultof<_>, item)

let inline check(tree : Tree) = tree.Check()
Expand Down
12 changes: 5 additions & 7 deletions tests/languageshootout_output/knucleotide.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ let frequencies (dna : string) (length : int) =
d.Values
|> Seq.map (!)
|> Seq.sum
yield! [for pair in d do
yield pair.Key.ToUpper(),
(float(pair.Value.Value) * 100.0 / float(total))]
yield! [for pair in d ->
pair.Key.ToUpper(),
(float(pair.Value.Value) * 100.0 / float(total))]
|> List.sortBy(snd >> (~-))
|> List.map(fun (s, c) -> sprintf "%s %.3f" s c)
yield ""]
Expand All @@ -52,14 +52,12 @@ let dna =
|> Seq.skip 1
|> String.concat ""

[for len in [1; 2] do
yield async { return frequencies dna len }]
[for len in [1; 2] -> async { return frequencies dna len }]
@ [for str in ["ggt"
"ggta"
"ggtatt"
"ggtattttaatt"
"ggtattttaatttatagt"] do
yield async { return countSubstring dna str }]
"ggtattttaatttatagt"] -> async { return countSubstring dna str }]
|> List.rev
|> Async.Parallel
|> Async.RunSynchronously
Expand Down
48 changes: 35 additions & 13 deletions tests/languageshootout_output/nbody.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,49 @@ type Planet =
Mass : float }

let jupiter =
{ X = 4.841431442; Y = -1.160320044; Z = -0.1036220445;
VX = 0.001660076643 * daysPerYear; VY = 0.007699011184 * daysPerYear;
VZ = -6.90460017e-05 * daysPerYear; Mass = 0.0009547919384 * solarMass }
{ X = 4.841431442
Y = -1.160320044
Z = -0.1036220445
VX = 0.001660076643 * daysPerYear
VY = 0.007699011184 * daysPerYear
VZ = -6.90460017e-05 * daysPerYear
Mass = 0.0009547919384 * solarMass }

let saturn =
{ X = 8.343366718; Y = 4.124798564; Z = -0.4035234171;
VX = -0.002767425107 * daysPerYear; VY = 0.004998528012 * daysPerYear;
VZ = 2.304172976e-05 * daysPerYear; Mass = 0.0002858859807 * solarMass }
{ X = 8.343366718
Y = 4.124798564
Z = -0.4035234171
VX = -0.002767425107 * daysPerYear
VY = 0.004998528012 * daysPerYear
VZ = 2.304172976e-05 * daysPerYear
Mass = 0.0002858859807 * solarMass }

let uranus =
{ X = 12.89436956; Y = -15.1111514; Z = -0.2233075789;
VX = 0.002964601376 * daysPerYear; VY = 0.00237847174 * daysPerYear;
VZ = -2.965895685e-05 * daysPerYear; Mass = 4.366244043e-05 * solarMass }
{ X = 12.89436956
Y = -15.1111514
Z = -0.2233075789
VX = 0.002964601376 * daysPerYear
VY = 0.00237847174 * daysPerYear
VZ = -2.965895685e-05 * daysPerYear
Mass = 4.366244043e-05 * solarMass }

let neptune =
{ X = 15.37969711; Y = -25.91931461; Z = 0.179258773;
VX = 0.002680677725 * daysPerYear; VY = 0.0016282417 * daysPerYear;
VZ = -9.515922545e-05 * daysPerYear; Mass = 5.15138902e-05 * solarMass }
{ X = 15.37969711
Y = -25.91931461
Z = 0.179258773
VX = 0.002680677725 * daysPerYear
VY = 0.0016282417 * daysPerYear
VZ = -9.515922545e-05 * daysPerYear
Mass = 5.15138902e-05 * solarMass }

let sun =
{ X = 0.0; Y = 0.0; Z = 0.0; VX = 0.0; VY = 0.0; VZ = 0.0; Mass = solarMass }
{ X = 0.0
Y = 0.0
Z = 0.0
VX = 0.0
VY = 0.0
VZ = 0.0
Mass = solarMass }

let offsetMomentum a =
let x, y, z =
Expand Down
4 changes: 2 additions & 2 deletions tests/languageshootout_output/regexdna2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let text = (regex ">.*\n|\n").Replace(input, "")
"aggg[acg]aaa|ttt[cgt]ccct"
"agggt[cgt]aa|tt[acg]accct"
"agggta[cgt]a|t[acg]taccct"
"agggtaa[cgt]|[acg]ttaccct"]
"agggtaa[cgt]|[acg]ttaccct"]
|> List.iter(fun s -> printf "%s %i\n" s ((regex s).Matches text).Count)

let newText =
Expand All @@ -34,7 +34,7 @@ let newText =
"S", "(c|g)"
"V", "(a|c|g)"
"W", "(a|t)"
"Y", "(c|t)"]
"Y", "(c|t)"]
|> List.fold (fun s (code, alt) -> (regex code).Replace(s, alt)) text

printf "\n%i\n%i\n%i\n" input.Length text.Length newText.Length
2 changes: 1 addition & 1 deletion tests/languageshootout_output/spectralnorm2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let RunGame n =
if (i < (nthread - 1))
then r1 + chunk
else n
yield async { return Approximate(u, v, tmp, r1, r2, barrier) }]
yield async { return Approximate(u, v, tmp, r1, r2, barrier) }]
|> Async.RunSynchronously
let vBv = aps |> Array.sumBy fst
let vv = aps |> Array.sumBy snd
Expand Down
3 changes: 2 additions & 1 deletion tests/stackexchange_output/color.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type MyFSColorTable() =
loadrgb.Split([|'\010'|])
|> Seq.skip 1
|> Seq.map(fun line -> line.Split([|'\009'|]))
|> Seq.filter(fun values -> values |> Seq.length = 3)
|> Seq.filter(fun values -> values
|> Seq.length = 3)
|> Seq.map(fun values -> string values.[0], string values.[2])
|> Seq.map(fun (rgb, name) -> rgb.Split([|' '|]), name)
|> Seq.map(fun (rgb, name) -> [|name, rgb.[0], rgb.[1], rgb.[2]|])
Expand Down
3 changes: 2 additions & 1 deletion tests/stackexchange_output/comments.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ type Comment =
let parseComment(line : string) =
match line.Split(';') with
| [|author; body|] ->
Some({ Author = author; Body = body })
Some({ Author = author
Body = body })
| _ -> None

let filterOutNone maybe =
Expand Down
8 changes: 4 additions & 4 deletions tests/stackexchange_output/mergesort.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ let rec merge (ar1 : 'a array) (ar2 : 'a array) =
yield! index indexnext
| false, false -> yield None }
let mergeindex = index(false, -1, -1)
[for (formar1, i, j) in mergeindex |> Seq.choose(id) do
yield if formar1
then ar1.[i]
else ar2.[j]]
[for (formar1, i, j) in mergeindex |> Seq.choose(id) ->
if formar1
then ar1.[i]
else ar2.[j]]

and mergesort =
function
Expand Down
2 changes: 1 addition & 1 deletion tests/stackexchange_output/rushhour.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let test (initialState : State) (brickInfo : Brick[])
else Some((rowID - 1, columnID), (rowID - 1, columnID))
if depth < 7 && not(isDuplicated mySet)
&& (let (_, columnLeft) = currentState.[0]
[|columnLeft + redLength..columnNum - 1|]
[|columnLeft + redLength..columnNum - 1|]
|> Array.forall(fun columnID -> checkVacancy(redRowNum, columnID))
|| horizontalBricksAll
|> Seq.tryFind(fun elem ->
Expand Down

0 comments on commit 8c0b065

Please sign in to comment.