💾 Archived View for idiomdrottning.org › hs2brev captured on 2023-06-16 at 16:28:43. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-03-20)
-=-=-=-=-=-=-
Haskell:
petMap :: (a -> b) -> [a] -> [b] petMap f [] = [] petMap f (x:xs) = f x : petMap f xs
Brev:
(define (pet-map f '()) '()) (define (pet-map f (x . xs)) (cons (f x) (pet-map f xs)))
Haskell:
petMember :: (Eq a) => a -> [a] -> Bool petMember x [] = False petMember x (y:ys) | x==y = True | otherwise = petMember x ys
Brev:
(define (pet-member x (y . ys)) (pet-member x ys)) (define (pet-member x (x . ys)) #t) (define (pet-member x '()) #f)
Haskell:
fold1:: (a ->a -> a) -> a -> [a] -> a fold1 f x [] = x fold1 f x (y : ys) = fold1 f (f x y) ys
Brev:
(define (fold1 kons acc '()) acc) (define (fold1 kons acc (x . xs)) (fold1 kons (kons acc x) xs))