home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 2
/
DATAFILE_PDCD2.iso
/
utilities
/
_gofer
/
!Gofer
/
archives
/
Demos
/
gs
/
match
< prev
next >
Wrap
Text File
|
1993-02-12
|
826b
|
28 lines
match [] ys = null ys
match ('*':ps) xs = or (map (match ps) (tails xs))
match (p:ps) [] = False
match (p:ps) (c:cs)
| p==c = match ps cs
| otherwise = False
-- Some combinatorial problems:
tails [] = [[]]
tails xs'@(x:xs) = xs' : tails xs
inits [] = [[]]
inits (x:xs) = [] : map (x:) (inits xs)
perms [] = [[]]
perms (x:xs) = concat (map (inter x) (perms xs))
where inter x [] = [[x]]
inter x ys'@(y:ys) = (x:ys') : map (y:) (inter x ys)
subs [] = [[]]
subs (x:xs) = subs xs ++ map (x:) (subs xs)
segs = concat . map tails' . reverse . inits
where tails' [] = []
tails' xs'@(_:xs) = xs' : tails' xs