Re: Quick question about delimiters

"Vesa Karvonen" <[email protected]> Fri, 1 Jun 2007 09:13:43 +0300
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
On 6/1/07, turbosol <[email protected]> wrote:
> I am in need of writing a function to take away delimters from a string so it
> will be a string of only letters.  I have to do this without using any built
> in functions... I feel like i am close, and logically, I fell like my code
> should work, but i am getting problems when i call it.  this is what i have
> so far.
>
> fun remele (x, L) =
> if null L then nil
> else if hd x = hd L then remele(x,(tl L))
> else if null(tl L) then remele(tl x, L)   -(*- I am not sure if this is
> correct, but i want too check to see
> else hd(L)::remele(x, tl L);         -(*if all elements were checked to then
> go to the next element to check
>
> remele([#" ", #",",#";",#".",#"\n",#"!",#"?"], explode("Hello, this is a
> string!"));
>
> should yield "hellothisisastring"
>
> any suggestions?

Consider writing an auxiliary function

  val contains : ''a list * ''a -> bool

with the property that contains (l, x) returns true if and only if the
list l contains an element equal to x.

-Vesa Karvonen

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/