Hi all, I am stuck at a piece of code and am not able to figure out the error. uptable::[[Char]]->[([Char],Int,Int,Int,Int)]->[([Char],Int,Int,Int,Int)] uptable (xf:xs) main_array = map (\(x,y,z,r,t)-> do if x==xf then tupup x y z r t second xs ) main_array here tupup and second are functions which are working . When compiling this it gives the error Syntax error in expression (unexpected `)') I am not able to figure out where I could have gone wrong. I have tried all bracketing combinations and nothing works. Navin
Missing else? On Wed, Feb 2, 2011 at 8:49 PM, Navin Rustagi <navin_kunta@yahoo.com> wrote:
Hi all,
I am stuck at a piece of code and am not able to figure out the error.
uptable::[[Char]]->[([Char],Int,Int,Int,Int)]->[([Char],Int,Int,Int,Int)] uptable (xf:xs) main_array = map (\(x,y,z,r,t)-> do if x==xf then tupup x y z r t second xs ) main_array
here tupup and second are functions which are working . When compiling this it gives the error
Syntax error in expression (unexpected `)')
I am not able to figure out where I could have gone wrong. I have tried all bracketing combinations and nothing works.
Navin
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Sorry, dumb of me doesn't give this error anymore. thanks, Navin ________________________________ From: Ramy Abdel-Azim <ramy.abdelazim@gmail.com> To: Navin Rustagi <navin_kunta@yahoo.com> Cc: Haskell@haskell.org Sent: Wed, February 2, 2011 7:55:09 PM Subject: Re: [Haskell] a quick question Missing else? On Wed, Feb 2, 2011 at 8:49 PM, Navin Rustagi <navin_kunta@yahoo.com> wrote: Hi all,
I am stuck at a piece of code and am not able to figure out the error.
uptable::[[Char]]->[([Char],Int,Int,Int,Int)]->[([Char],Int,Int,Int,Int)] uptable (xf:xs) main_array = map (\(x,y,z,r,t)-> do if x==xf then tupup x y z r t second xs ) main_array
here tupup and second are functions which are working . When compiling this it gives the error
Syntax error in expression (unexpected `)')
I am not able to figure out where I could have gone wrong. I have tried all bracketing combinations and nothing works.
Navin
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
No need to apologize. Not dumb of you. The mandatory else is unusual. I don't personally know of any other language that requires an else for every if. On Wed, Feb 2, 2011 at 9:07 PM, Navin Rustagi <navin_kunta@yahoo.com> wrote:
Sorry, dumb of me doesn't give this error anymore. thanks, Navin ------------------------------ *From:* Ramy Abdel-Azim <ramy.abdelazim@gmail.com> *To:* Navin Rustagi <navin_kunta@yahoo.com> *Cc:* Haskell@haskell.org *Sent:* Wed, February 2, 2011 7:55:09 PM *Subject:* Re: [Haskell] a quick question
Missing else?
On Wed, Feb 2, 2011 at 8:49 PM, Navin Rustagi <navin_kunta@yahoo.com>wrote:
Hi all,
I am stuck at a piece of code and am not able to figure out the error.
uptable::[[Char]]->[([Char],Int,Int,Int,Int)]->[([Char],Int,Int,Int,Int)] uptable (xf:xs) main_array = map (\(x,y,z,r,t)-> do if x==xf then tupup x y z r t second xs ) main_array
here tupup and second are functions which are working . When compiling this it gives the error
Syntax error in expression (unexpected `)')
I am not able to figure out where I could have gone wrong. I have tried all bracketing combinations and nothing works.
Navin
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
On Wed, Feb 02, 2011 at 10:01:08PM -0500, Ramy Abdel-Azim wrote:
No need to apologize. Not dumb of you. The mandatory else is unusual. I don't personally know of any other language that requires an else for every if.
Indeed. Haskell's if ... then ... else ... is akin to C's ... ? ... : ... ternary operator rather than standard if/then/else clauses. Remember that if ... then ... else ... is an _expression_, so must have a value irrespective of whether the condition is true or false; therefore, there must be an else clause. Julian
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2/2/11 22:01 , Ramy Abdel-Azim wrote:
No need to apologize. Not dumb of you. The mandatory else is unusual. I don't personally know of any other language that requires an else for every if.
Haskell's if is an expression, best compared to the ?-: ternary operator in C and Perl or Python's if-else operator instead of to a control structure. - -- brandon s. allbery [linux,solaris,freebsd,perl] allbery.b@gmail.com system administrator [openafs,heimdal,too many hats] kf8nh -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk1LRsQACgkQIn7hlCsL25XSPACfRTlbLfBO6bKmg9EH4RPGSdMx SvoAnjakFqCArV9GRczvi2b1HZ6BZTjO =9Vvo -----END PGP SIGNATURE-----
Can I suggest you take this discussion to either the haskell-beginners list, or haskell-cafe? This list (haskell@haskell.org) is intended primarily for announcements. Regards, Malcolm On 03 Feb, 2011,at 09:33 AM, Matthias Görgens <matthias.goergens@googlemail.com> wrote:
uptable::[[Char]]->[([Char],Int,Int,Int,Int)]->[([Char],Int,Int,Int,Int)] uptable (xf:xs) main_array = map (\(x,y,z,r,t)-> do if x==xf then tupup x y z r t second xs ) main_array
Why do you have a `do' in that snippet? _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
participants (6)
-
Brandon S Allbery KF8NH -
Julian Gilbey -
malcolm.wallace -
Matthias Görgens -
Navin Rustagi -
Ramy Abdel-Azim