Maris Orbidans

2017-11-26 20:54:21 UTC

https://gist.github.com/maruks/18fb2a23e1a2d019dc37563aa08ee46f

blur : Dict(Int,Int) Int -> ( Int, Int ) -> Int

blur cells ( x, y ) =

let

xs =

range (x - 1) (x + 1)

ys =

range (y - 1) (y + 1)

points =

concatMap (\x -> map (\y -> ( x, y )) ys) xs

*( sum, num )* =

foldr

(\p ( s, n ) ->

case Dict.get p cells of

Just h ->

* ( sum + h, num + 1 ) -- ( s + h, n + 1 )*

Nothing ->

( s, n )

)

( 0, 0 )

points

in

sum // num

blur : Dict(Int,Int) Int -> ( Int, Int ) -> Int

blur cells ( x, y ) =

let

xs =

range (x - 1) (x + 1)

ys =

range (y - 1) (y + 1)

points =

concatMap (\x -> map (\y -> ( x, y )) ys) xs

*( sum, num )* =

foldr

(\p ( s, n ) ->

case Dict.get p cells of

Just h ->

* ( sum + h, num + 1 ) -- ( s + h, n + 1 )*

Nothing ->

( s, n )

)

( 0, 0 )

points

in

sum // num

--

You received this message because you are subscribed to the Google Groups "Elm Discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+***@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups "Elm Discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+***@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.