I'm assuming you're expecting an error because `sum` and `num` are values that are referred to within their own definition?
The rule the compiler currently follows is that referring to yourself is allowed if the reference is inside a lambda. (In this example, the compiler does know whether or not `foldr` is going to immediately call the lambda or leave it unevaluated.) On Sun, Nov 26, 2017 at 12:54 PM, Maris Orbidans <[email protected]> wrote: > > > 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 > > -- > 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 [email protected]. > 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
