[Haskell-fr] _

Olivier Thauvin nanardon at nanardon.zarb.org
Thu Sep 20 20:21:41 EDT 2007


Le jeudi 20 septembre 2007, Dupont Corentin a écrit :

> > myfilter :: [String] -> [String]
> > myfilter [] = []
> > myfilter (x:xs) =
> >     case x of
> >         '#':_ -> myfilter(xs)
> >         otherwise -> x:myfilter(xs)
>
> Dans ton exemple je ne comprend pas,
> le x est bien un seul caratère?

Non, si tu regarde bien le prototype de la fonction, tu verras [String], et 
String est alias de [Char]. Donc dans (x:xs), x est le premier élément d'un 
tableau de chaine, donc un tableau de caractères.

> comment peut-il matcher avec '#':_ qui est me semble t-il une chaine?

Si x est un tableau de Char ([Char]), il peut matcher  '#':_ donc.

Cordialement.

PS: qq1 d'autre a déjà répondu, mais je m'en aperçois après avoir tapé, alors 
j'envois quand même ;)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://www.haskell.org/pipermail/haskell-fr/attachments/20070921/5382871a/attachment-0001.bin


More information about the Haskell-fr mailing list