From 04fc94a522b27ba121c3a0c2d899f6905b1d0d12 Mon Sep 17 00:00:00 2001 From: Preetham Gujjula Date: Thu, 4 Apr 2024 21:07:36 -0700 Subject: [PATCH] Update ALGORITHM.md --- docs/ALGORITHM.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/docs/ALGORITHM.md b/docs/ALGORITHM.md index 0c5f50a..4f4f61c 100644 --- a/docs/ALGORITHM.md +++ b/docs/ALGORITHM.md @@ -151,13 +151,6 @@ applyMerge :: (Ord c) => (a -> b -> c) -> [a] -> [b] -> [c] where `applyMerge f xs ys` is a sorted list of all `f x y`, for each `x` in `xs` and `y` in `ys`. In particular, `smooth3 = applyMerge (*) powersOf2 powersOf3`. -We can also define a more general - -```haskell -applyMergeBy :: (c -> c -> Ordering) -> (a -> b -> c) -> [a] -> [b] -> [c] -``` - -taking a custom comparison function. ## Implementation and complexity @@ -194,7 +187,7 @@ zs :: [Int] zs = 0 : concatMap (\i -> [i, -i]) [1..] gaussianInts :: [Complex Int] -gaussianInts = applyMergeBy (comparing (\a b -> a*a + b*b)) (:+) ints ints +gaussianInts = map snd (applyMerge (\x y -> (x*x + y*y, x :+ y)) ints ints) ``` Square-free integers ([Wikipedia](https://en.wikipedia.org/wiki/Square-free_integer)):