Skip to content

Commit

Permalink
Update ALGORITHM.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pgujjula authored Apr 5, 2024
1 parent 34c70d4 commit 04fc94a
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions docs/ALGORITHM.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)):
Expand Down

0 comments on commit 04fc94a

Please sign in to comment.