PDA

View Full Version : caml functions


meaculpa1113
10-04-2003, 06:43 PM
hi..

i m a java/c++ programmer, and just recently was required to learn some functional programming.. i wont lie abt it, this is a question from an assignment that i was given.. if someone could please give me some pointers on how to go abt it, it will be much appreciated.. thank you..

http://www.lmc.cs.sunysb.edu/~cse307/Fall03/homeworks/hw2.html

i m not even too sure that i understand the question properly.. if someone could please shed some light.. it will be mucch appreciated..

thank you

meaculpa1113
10-05-2003, 06:11 PM
ok.. this is where i m now..

i have solved the first question to the point where i get a list of all the elements, but they do contain duplicates in them.. i m not sure how to get rid of the duplicates...

and i also tried starting on question two... i m not sure how to go abt it.. any hints anyone??

pls help!

meaculpa1113
10-07-2003, 03:37 PM
hey guys..

someone pls help me..!!

i have gotten a lot more done now.. now my questions are very generic..

one of them is..

if i have a list of elements, lets say [1;2;3;1;2;3] how do i get rid of duplicates..??

this is wat i have written rigth now..

# let rec remDup a =
match a with
[] -> [""]
| x :: xs -> if List.mem x c
then remDup xs
else
x :: c @ remDup xs;;

i know that there is something wrong with it.. but cant figure out wat.. someone pls help..!!!

I M SURE THAT THERE IS SOMEBODY OUT THERE WHO KNOWS HOW TO DO THIS.. COME ON GUYS.. PLS HELP..!!

THX..

sicarius
10-07-2003, 04:47 PM
I'd really like to help but my only functional language is Haskell. Sorry that no one seems to be able to help you right now.