Functional Programming

5.0(1)
studied byStudied by 15 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/48

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

49 Terms

1
New cards

program

description of a specific computation

2
New cards

function

a rule that associates to each x from some set X of values a unique y from a set Y of values.

3
New cards

domain

The set X is called the ____________ of f.

<p>The set X is called the ____________ of f. </p>
4
New cards

range

set Y is called the ________ of f.

<p>set Y is called the ________ of f.</p>
5
New cards

independent variable

The x in f(x), which represents any value from X

6
New cards

dependent variable

the y from the set Y, defined by the equation y = f(x)

<p>the y from the set Y, defined by the equation y = f(x)</p>
7
New cards

partial function

Sometimes f is not defined for all x in X

8
New cards

total

function that is defined for all x in X

9
New cards

function definition

describes how a value is to be computed using formal

parameters.

10
New cards

function application

a call to a defined function using actual parameters, or the values that the formal parameters assume for a particular computation

11
New cards

In imperative programming, variables refer to memory locations that store values. In functional programming, variables are bound to values and cannot change.

What is a key difference between imperative and functional programming regarding variables?

12
New cards

In mathematics, variables always stand for actual values and do not refer to memory locations or assignments, unlike imperative programming.

How does mathematics treat variables compared to programming?

13
New cards

Imperative Programming (Variables)

variables refer to memory locations that store values, allowing their contents to change over time.

14
New cards

Functional Programming (Variables)

variables are bound to values rather than memory locations. Once assigned, their values cannot change.

15
New cards

Variable in Mathematics

a variable always represents a fixed value and does not refer to a memory location or allow reassignment.

16
New cards

Composition

An operation on functions that takes two functions as parameters and produces a new function as the result.

17
New cards

Higher-Order Function

A function that takes other functions as parameters, returns a function, or both.

18
New cards

Delayed Evaluation

A strategy where function parameters are not evaluated immediately but only when their values are needed.

19
New cards

Applicative Order Evaluation

An evaluation rule where all parameters of a function are evaluated at the time of the function call, regardless of necessity.

20
New cards

Short-Circuit Evaluation

A Boolean evaluation technique where further computation stops as soon as the result is determined, such as in and and or expressions.

21
New cards

Nonstrict Function

A function that can produce a result even when some of its parameters are undefined or contain incomplete data.

22
New cards

Strict Function

A function that requires all parameters to be fully evaluated before execution, making implementation simpler but less flexible.

23
New cards

TRUE

Delayed evaluation allows nonstrict functions to return well-defined results even when some sub-expressions are undefined. TRUE OR FALSE

24
New cards

Lazy Evaluation

A strategy where expressions are only evaluated when their values are needed, allowing efficient computation and handling of infinite structures.

25
New cards

Stream

A partially computed list where elements are generated on demand, enabling the handling of potentially infinite lists in functional programming.

26
New cards

Lambda Calculus

was invented by Alonzo Church (1903 -1995), a mathematician in Princeton University.

27
New cards

Lambda Calculus

  • It would be a function that takes a single input called x, process it in some way and produces the output, the number x+1 that refers to as increment of x.

  • purely mathematical function and there’s no internal state that we can look inside a function.

28
New cards
  • the variables

  • the lambda notation build functions

  • a way of applying functions.

Lambda Calculus only got three things, which are:

29
New cards

Lisp

A functional programming language developed in the 1950s–1960s, designed for list processing and based on lambda calculus.

30
New cards

John McCarthy

Developed Lisp

31
New cards

Scheme

A dialect of Lisp that follows the principles of functional programming and is influenced by lambda calculus.

32
New cards

Uniform Representation

Scheme represents both programs and data using a single general data structure—the list.

33
New cards

Metacircular Interpreter

An interpreter written in the same language it interprets, used to define the language itself in Scheme.

34
New cards

Automatic Memory Management

Scheme's run-time system automatically handles memory allocation and garbage collection.

35
New cards

Atoms

are like the literal constants and identifiers of an imperative language, the include numbers, characters, strings, names, functions, and a few other constructs.

36
New cards

parenthesized expression

sequence of zero or more expressions separated by spaces

and surrounded by parentheses

37
New cards

extended Backus-Naur form

This syntax is expressed in a notation called?

<p>This syntax is expressed in a notation called?</p>
38
New cards

Atomic Literals in Scheme

Numbers, characters, and strings that evaluate to themselves without requiring further computation.

39
New cards

Identifiers in Scheme

Symbols (except keywords) that are looked up in the current environment and replaced by their associated values.

40
New cards

Environment in Scheme

A symbol table that stores variable bindings and their corresponding values.

41
New cards

Applicative Order Evaluation in Scheme

A strategy where all sub-expressions are evaluated first, following a bottom-up traversal of the expression tree.

42
New cards

ML (MetaLanguage)

A functional programming language developed in the late 1970s as part of the Edinburgh Logic for Computable Functions (LCF) system.

43
New cards

Edinburgh Logic for Computable Functions (LCF)

A system designed for proving program correctness, which led to the development of ML.

44
New cards

Robin Milner

A key developer of ML and the Hindley-Milner type inference system.

45
New cards

Hindley-Milner Type Checking

A strong type inference system based on pattern matching, used in ML and Haskell.

46
New cards

Haskell

a pure functional language whose development began in the late 1980s, primarily at Yale University and the University of Glasgow. Known for lazy evaluation and advanced functional features.

47
New cards

David A. Turner

A key figure in the development of purely functional lazy languages, leading to the Miranda programming language, which influenced Haskell.

48
New cards

Monads

A mechanism used to handle side effects, such as I/O, in a pure functional programming paradigm.

49
New cards

Layout Rule in Haskell

A rule that uses indentation and formatting instead of explicit syntax elements like semicolons or brackets.