tobogganSe connecter

louise

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

25 lignes · 513 octetsBrut · Historique
1// A map/filter/fold pipeline over a million integers, ten times (each
2// round a little longer, so that no compiler computes it only once).
3
4import std/io
5import std/list
6
7fn round :: k: Int acc: Int -> Int
8{
9 if k == 0
10 {
11 acc
12 }
13 else
14 {
15 let doubled = list.map (list.range 1 (1000000 + k)) fn x { x * 2 }
16 let sum =
17 list.fold (list.filter doubled fn x { x % 3 == 0 }) 0 fn a x { a + x }
18 round (k - 1) (acc + sum)
19 }
20}
21
22pub fn main :: -> () / <io>
23{
24 io.println (show (round 10 0))
25}