Re: I need help! Substrings
turbosol <[email protected]> Thu, 31 May 2007 07:12:28 -0700 (PDT)
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
Thanks for all the help! I really appreciate it. After working this through
my head over and over again, i decided to take a different approach and
rather than check for the first char from the first string, i decided to
create a function which found the length of the string, and would check the
entire string against the same amount of chars from the other string and
incriment if not found, and return the -1 if the string being checked
against is less than the original string. thanks again for all the help.
turbosol wrote:
>
> So i signed up for my last compscience class so i can graduate... the
> class i needed was canceled so i was put into a more difficult class for
> majors. Comp science is my minor... anyways, I am currently doing twice
> the work i would normally do in half the time. I am lost. if anyone can
> help me, i would appreciate it SOOO much.
>
> I need to write a function SubString : string * string -> int that checks
> whether the first string is a substring of the second (case sensitive).
> return the index position (starting from 0) if the string is a substring
> or -1 otherwise. for multiple occurances, just return the index of the
> first appearance. you may assume both input parameters are strings.
>
> subString("ab","abcdefg")=> 1
> subString("aaa","aaaa")=>0
> subString("bc","absge") =>-1
> subString("ab","cdabd") => 2
>
--
View this message in context: http://www.nabble.com/I-need-help%21--Substrings-tf3836438.html#a10894280
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/