Tips of Conditional Expression

I know the following: [1] That the general form of conditional expression is: if * Boolean_expression* then *exp1* else *exp2 *[2] That a conditional expression must always have both a then and an elseexpression. [3] That both *exp1* and *exp2* must have the same type, which is the type of the entire conditional expression. [4] That *exp1* must be <true-value> and *exp2* must be <false-value> Reference: Discrete Mathematics Using Computer by John O'Donnell and et al. (Second Edition) My question: Is it possible that exp1 and exp 2 be different function calls of another functions (separately) elsewhere within the same program? Note: My Boolean_expression is Boolean My *exp1* is a function call elsewhere within the same program (more like a subroutine) My *exp2* is another function call also elsewhere within the same program. Tope South Africa

TOPE KAREM wrote:
I know the following:
[1] That the general form of conditional expression is: if *Boolean_expression* then /exp1/ else /exp2 /[2] That a conditional expression must always have both a then and an else expression. [3] That both /exp1/ and /exp2/ must have the same type, which is the type of the entire conditional expression. [4] That /exp1/ must be <true-value> and /exp2/ must be <false-value>
Reference: Discrete Mathematics Using Computer by John O'Donnell and et al. (Second Edition)
My question: Is it possible that exp1 and exp 2 be different function calls of another functions (separately) elsewhere within the same program? Note: My Boolean_expression is Boolean My /exp1/ is a function call elsewhere within the same program (more like a subroutine) My /exp2/ is another function call also elsewhere within the same program.
I'm not sure what you're asking, but exp1 and exp2 may have (the same) function type: if <cond> then map else filter :: (Bool -> Bool) -> [Bool] -> [Bool] HTH Christian

Thanks. My question is whether it can call a function (say map) previously
defined elsewhere in the program. Same goes for filter.
Tope
On Fri, Feb 22, 2008 at 6:04 AM, Christian Maeder
I know the following:
[1] That the general form of conditional expression is: if *Boolean_expression* then /exp1/ else /exp2 /[2] That a conditional expression must always have both a then and an else expression. [3] That both /exp1/ and /exp2/ must have the same type, which is the type of the entire conditional expression. [4] That /exp1/ must be <true-value> and /exp2/ must be <false-value>
Reference: Discrete Mathematics Using Computer by John O'Donnell and et al. (Second Edition)
My question: Is it possible that exp1 and exp 2 be different function calls of another functions (separately) elsewhere within the same
TOPE KAREM wrote: program?
Note: My Boolean_expression is Boolean My /exp1/ is a function call elsewhere within the same program (more like a subroutine) My /exp2/ is another function call also elsewhere within the same program.
I'm not sure what you're asking, but exp1 and exp2 may have (the same) function type:
if <cond> then map else filter :: (Bool -> Bool) -> [Bool] -> [Bool]
HTH Christian

Am Freitag, 22. Februar 2008 15:22 schrieb TOPE KAREM:
Thanks. My question is whether it can call a function (say map) previously defined elsewhere in the program. Same goes for filter.
Tope
Like oddlyMakeEven [] = [] oddlyMakeEven ks@(k:_) = if odd k then map (*2) ks else filter even ks ? Sure, each branch can be an arbitrarily complex expression. HTH, Daniel

TOPE KAREM wrote:
Thanks. My question is whether it can call a function (say map) previously defined elsewhere in the program. Same goes for filter.
I'm still not sure what to answer. If map and filter were user defined functions they may occur anywhere in your current module (or must be imported) and you can apply any argument in scope (of proper type). You could i.e. apply "(if <cond> then map else filter)" to "id" which is the same as "if <cond> then map id else filter id" C.
On Fri, Feb 22, 2008 at 6:04 AM, Christian Maeder
mailto:Christian.Maeder@dfki.de> wrote: I'm not sure what you're asking, but exp1 and exp2 may have (the same) function type: if <cond> then map else filter :: (Bool -> Bool) -> [Bool] -> [Bool]

Thank you all. I am satisfied with all your inputs.
Tope
On Fri, Feb 22, 2008 at 7:17 AM, Christian Maeder
TOPE KAREM wrote:
Thanks. My question is whether it can call a function (say map) previously defined elsewhere in the program. Same goes for filter.
I'm still not sure what to answer. If map and filter were user defined functions they may occur anywhere in your current module (or must be imported) and you can apply any argument in scope (of proper type).
You could i.e. apply "(if <cond> then map else filter)" to "id" which is the same as "if <cond> then map id else filter id"
C.
On Fri, Feb 22, 2008 at 6:04 AM, Christian Maeder
mailto:Christian.Maeder@dfki.de> wrote: I'm not sure what you're asking, but exp1 and exp2 may have (the same) function type: if <cond> then map else filter :: (Bool -> Bool) -> [Bool] -> [Bool]
participants (3)
-
Christian Maeder
-
Daniel Fischer
-
TOPE KAREM