Reputation: 0 Apprentice
- Active Posts:
- 19 (0.03 per day)
- 01-December 11
- Profile Views:
- Last Active:
- Nov 08 2012 03:39 PM
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Who Cares
- Your Car:
- Dream Kudos:
Posts I've Made
Posted 2 Aug 2012
Posted 12 Dec 2011After that I've tried I've almost everything that I can remember. I believe that my best approach was something like:
xxs = [(11,22,[(33,33,33),(44,44,44)]),(55,66,[(77,77,77),(88,88,88)])] foo  _ _ _ = error "-.-/>" foo ((x1:x2:x3):xs) 1 1 y = (x1:x2:y): xs -- I'm sure that there is some errors foo (xa:xb:xc:xs) n p y = xa:xb:((foo xc (p-1) y): (xs (n-1))) -- wont compile ://>
Posted 11 Dec 2011well sepp2k, let me just say that if you're not a teacher... you should considerate that!
Thanks you very much!
But now... you just made me review my full assignment! lol
So, one more question. If I have:
xs = [(11,22,[(33,33,33),(44,44,44)]),(55,66,[(77,77,77),(88,88,88)])]
Can I use constructors to pattern match the lists of tuples inside the tuples from the xs list?
I.e. can I "replace" the nth tuple from the xs list (33,33,33)or(44,44,44) or (77,77,77)or (88,88,88)? I've try to do that, but without success.
Based on your post, I'm now able to change the tuples of a list of tuples:
xxs = [(11,11,11),(11,11,11),(11,11,11)] foo  _ _ = error "List does not have enough elements" foo ((x1):xs) 1 y = (y) : xs foo (x:xs) n y = x : (foo xs (n-1) y)
After that I've tried I've almost everything that I can remember. I believe that my best approach was something like: foo = (x1:x2:x3:xs) n p y = x1:x2:y: xs
I've tried for hours... And I didnt even know if it's possible! :S
Posted 11 Dec 2011You should rewrite that function so it can handle lists of any length.
That is my biggest problem, since the beginning. My codes works fine for smaller lists (like my 2 or 3 restaurants)... but if I have a longer list (like 100 or 200 restaurants)?
From your response, I assume that there's a way to "handle lists of any length". Am I far away from achieve it?
Posted 11 Dec 2011@ishkabible
ty for yours suggestions.
About "code 2" ... I've only tried it because... well, more for study. with a small list, it could be nice, but I really agree: this code also make my "eyes bleed".
The "code 3" was initially something like:
foo x y ((_,_,z):xxs) = (x,y,z):xxs
but i didnt wanna pass a list as argument. So, I create an aux function.
About the use of tuples, unfortunately it's an assignment requirement.
All the other ideas... I'll add them!!
Thank you very much!
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
- Years Programming: