mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
Abschnitt über Arithmetik in Prolog hinzugefügt; misc
This commit is contained in:
parent
82dd24d55b
commit
80e8df59d6
20 changed files with 194 additions and 27 deletions
|
@ -1,15 +0,0 @@
|
|||
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]]
|
Loading…
Add table
Add a link
Reference in a new issue