Skip to content

Commit 9692125

Browse files
committed
[exercise] 5.8
1 parent 747a997 commit 9692125

File tree

1 file changed

+5
-0
lines changed
  • chapter05-List-comprehensions

1 file changed

+5
-0
lines changed

chapter05-List-comprehensions/8.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
find :: Eq a => a -> [(a, b)] -> [b]
2+
find k t = [v | (k', v) <- t, k == k']
3+
4+
positions :: Eq a => a -> [a] -> [Int]
5+
positions x xs = find x [(x, i) | (x, i) <- zip xs [0..]]

0 commit comments

Comments
 (0)