Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Conditional (computer programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Haskell==== {{Main|Haskell (programming language)}} In [[Haskell (programming language)|Haskell]] 98, there is only an ''if expression'', no ''if statement'', and the <code>else</code> part is compulsory, as every expression must have some value.<ref name="haskell98report">''[http://www.haskell.org/onlinereport/ Haskell 98 Language and Libraries: The Revised Report]''</ref> Logic that would be expressed with conditionals in other languages is usually expressed with [[pattern matching]] in recursive functions. Because Haskell is [[lazy evaluation|lazy]], it is possible to write control structures, such as ''if'', as ordinary expressions; the lazy evaluation means that an ''if function'' can evaluate only the condition and proper branch (where a strict language would evaluate all three). It can be written like this:<ref name="haskell-ifthenelse-proposal">"[http://haskell.org/haskellwiki/If-then-else If-then-else Proposal on HaskellWiki]"</ref> <syntaxhighlight lang="haskell"> if' :: Bool -> a -> a -> a if' True x _ = x if' False _ y = y </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)