PlanetMath (more info)
 Math for the people, by the people. Sponsor PlanetMath
Encyclopedia | Requests | Forums | Docs | Wiki | Random | RSS  
Login
create new user
name:
pass:
forget your password?
Main Menu
Owner confidence rating: High Entry average rating: No information on entry rating
Haskell (Definition)

Haskell is a computer programming language designed by a committee in 1990 to consolidate the best features of the many purely functional programming languages that were created in the late 1980s. Haskell is thus neither a procedural programming language nor an object-oriented one, although it offers monads such as do to support procedural programming and classes with inheritance to support object-oriented programming (there is also a variant of Haskell called O'Haskell which includes more support for object-oriented programming). In general, Haskell programs are most naturally written declaratively.

The standard version of the language is Haskell 98; Haskell 2007 hasn't been released yet but is expected to be only a minor revision of Haskell 98.

The standard Haskell prelude includes the function gcd, which computes the greatest common divisor of two integers. The following Haskell code is a reimplementation of the gcd function.

-- gcd.hs -- compute the gcd of two integers
-- View this page in TeX mode for documentation and license.

mygcd :: Int -> Int -> Int
mygcd m n
| (n < 0) = mygcd m (abs n)
| (n == 0) = m
| (m < n) = mygcd n m
| otherwise = mygcd n (mymod m n)

mydiv :: Int -> Int -> Int
mydiv m n
| (m < 0) = negate (mydiv (negate m) n)
| (n < 0) = negate (mydiv m (negate n))
| (m < n) = 0
| otherwise = 1 + mydiv (m-n) n

mymod :: Int -> Int -> Int
mymod m n = m - n * (mydiv m n)




Anyone with an account can edit this entry. Please help improve it!

"Haskell" is owned by PrimeFan. [ full author list (3) ]
(view preamble | get metadata)

View style:

Log in to rate this entry.
(view current ratings)

Cross-references: integers, greatest common divisor, function, monads, NOR, computer
There are 5 references to this entry.

This is version 3 of Haskell, born on 2007-03-04, modified 2007-03-09.
Object id is 9019, canonical name is Haskell.
Accessed 1580 times total.

Classification:
AMS MSC68N15 (Computer science :: Software :: Programming languages)

Pending Errata and Addenda
None.
Discussion
Style: Expand: Order:
forum policy

No messages.

Interact
post | correct | update request | add derivation | add example | add (any)