2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-25 22:38:04 +02:00

Fixpunktkombinatoren; Haskell-Beispiele

This commit is contained in:
Martin Thoma 2014-03-20 13:42:52 +01:00
parent e910561dfe
commit 0174aa0cc6
5 changed files with 129 additions and 6 deletions

View file

@ -0,0 +1,15 @@
module Intersect where
intersect :: (Ord t) => [t] -> [t] -> [t]
intersect a [] = []
intersect [] a = []
intersect (x:xs) (y:ys)
| x == y = x : intersect xs ys
| x < y = intersect xs (y:ys)
| y > y = intersect (x:xs) ys
intersectAll :: (Ord t) => [[t]] -> [t]
intersectAll (l:ls) = (foldr intersect l) ls
intersectAll [] = undefined
multiples n = [n*k | k <- [1..]]
commonMultiples a b c = intersectAll [ multiples n | n <- [a,b,c]]

View file

@ -0,0 +1,2 @@
fibs :: [Integer]
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)