Skip main navigation

Zip that List

The zip function is used to combine a pair of lists into a list of pairs. Since lists are such fundamental data structures in functional programming, it’s important to be …

Reduction, Functions and Lists

Reduction A model of program execution A programmer needs a concrete model for how a program is executed. For imperative programs, we can execute statement by statement, keeping track of …

Summary

Haskell programs compute by reduction, i.e. gradually replacing expressions by their values. A function takes one or more arguments and computes a result. Given the same arguments, the result will …

Summary

Expressions in Haskell are similar to those in other languages. There are only expressions in Haskell, i.e. no statements. Things that look like assignments are not updates of values but …

More Basic Elements by Example

A few more basic (and not-so-basic) elements of Haskell through comparison with other languages. We will not go into detail on the Haskell constructs, just show the similarities with constructs …

Basic Elements By Example

 Expressions In almost all programming languages you can create expressions such as: (b*b-4*a*c)/2*a and you can assign these expressions to variables: v = (b*b-4*a*c)/2*a In Haskell, you can do this …

Introduction to Expressions and Equations

Expressions Haskell has no statements, only expressions! In an imperative language like C or Java, there are expressions that denote small scale computations (2*x), and statements that handle sequencing, looping, …

Dollars in Haskell

The dollar operator is useful for greater flexibility in function application, although you could use more brackets instead. There are further details about dollars on the Learn You a Haskell …

Introducing Pairs in Haskell

Pairs, like lists, are a technique for building composite data out of individual values. A pair of Integers can be written as: (1,2) and a pair of Strings might be: …