Re: Quick question about delimiters

turbosol <[email protected]> Sat, 2 Jun 2007 10:29:02 -0700 (PDT)
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
I feel like i am extremely close, but this is not woring.  Any help will be
much appreciated.  this is the back bone of what i am trying to write to
take away multiple elements from a list. I think i can figure the rest out
with helper functions, I think i just need to get this working first.  Its
the remall function that i am having problems with.  It is supposed to pass
each element of list S thought the remove function which will remove each
element from list L.


fun remele (x, L) =
if null L then nil
else if x = hd L then remele(x,tl L)
else hd(L)::remele(x, tl L);

fun remall(S,L) =
if null S then L
else remall(tl(S), remele(hd(S), L);



turbosol 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?
> 

-- 
View this message in context: http://www.nabble.com/Quick-question-about-delimiters-tf3850025.html#a10929447
Sent from the SML/NJ mailing list archive at Nabble.com.


-------------------------------------------------------------------------
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/