Let 2. Abstractions

0.0(0)
studied byStudied by 6 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/36

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

37 Terms

1
New cards

What is programming?

Programming is the process of creating a program.

2
New cards

What do you represent a program?

We represent a program with a language(programming language)

3
New cards

What are high-level languages?

F#, Haskell, Skala

4
New cards

What are low-level languages?

Assembly language

5
New cards

What are the pros and cons of low-level programming languages?

Low-level programming languages provide a way to directly manipulate the computer hardware.

6
New cards

What are the pros and cons of low-level programming languages?

High-level programming languages provide a way to abstract our ideas about computations

7
New cards

Why abstraction matters?

1. Abstraction hides unnecessary details, making things easier to understand.

2. Abstraction allows us to focus on the important parts of a problem.

3. Abstraction allows us to build complex systems by combining simple ideas (because abstracted ideas can be easily combined to form more complex ideas).

8
New cards

What does good programming language do?

A good programming language should help developers abstract things away thereby making the code readable.

9
New cards

What does F# do?

  • #F is a functional first language.

  • F# is a multi-paradigm language that prioritizes functional programming.

  •  F# code is concise and easy to read.

  •  F# code is likely to be correct.

  •  F# code requires less maintenance cost.

10
New cards

What is a program?

A program is a series of computations (functions) that eventually result in a value.

11
New cards

What do we use to represent computations?

Functions

12
New cards

What do we build abstractions and manipulate data with?

Functions

13
New cards

What is imperative programming?

Imperative programming is all about firing up commands: “do this, do that, etc.”

14
New cards

What is functional programming?

Functional programming is all about writing down functions denoting values.

15
New cards

What do we call functional programming as?

Value-oriented programming.

16
New cards

What is the basic building block for programs?

Expressions

17
New cards

What is expression?

An expression is abstraction that can be evaluated by the programming language interpreter to produce a value.

18
New cards

What is semantics?

Every expression has its own semantics, which describes what kind of computation the expression represents.

19
New cards

When do we say a program is well-typed?

When all expression in the program satisfy the type constraints.

20
New cards

What does expression have?

Each expression has its own type, which poses constrains on expression.

21
New cards

What does evaluation of an expression fail?

When the type checking fails.

22
New cards

What is a function?

A function is an expression that takes in an expression and returns an expression.

23
New cards

How do you call a function?

Give a name to call it. We say we apply a function f to an argument a, when we call f with a as a parameter

24
New cards

Does function application need parentheses?

Function applications typically do not require parentheses in F#.

25
New cards

What id REPL?

Read-Evaluate-Print Loop.

26
New cards

A REPL for F# is…

fsi (or fsharpi).

27
New cards

Where the result of evaluation is stored after printing it out?

In a special identifier, called “it”.

28
New cards

What do we use to indicate type of expression?

colon ()

<p>colon ()</p>
29
New cards

How can we write a function that takes in two or more arguments without introducing a new syntax?

Function is an expression.
Therefore, we can return a function from a function.

30
New cards

What is currying?

The technique of translating the evaluation of a function takes multiple arguments into evaluating a sequence of functions, each with a single argument'.

<p>The technique of translating the evaluation of a function takes multiple arguments into evaluating a sequence of functions, each with a single argument'.</p>
31
New cards

What is function pipelining?

We can apply function in a reverse order by using the infix operator (|>). This operator allows function pipelining, which links a sequence of functions in an intuitive manner.

<p><span>We can apply function in a reverse order by using the infix operator (|&gt;). This operator allows function pipelining, which links a sequence of functions in an intuitive manner.</span></p>
32
New cards

What is anonymous function?

We call a function without its name as an anonymous function, a.k.a., lambda expression (λ).

<p><span>We call a function without its name as an anonymous function, a.k.a., lambda expression (λ).</span></p>
33
New cards

How to make function more readable if we take 2 arguments?

A function taking two arguments can often be more readable if we use infix notation.

<p><span>A function taking two arguments can often be more readable if we use infix notation.</span></p>
34
New cards

Nested functions

knowt flashcard image
35
New cards

Evaluation rule?

knowt flashcard image
36
New cards

What is evaluation?

Evaluation is a procedure, i.e., a function, that takes in an expression as input, and returns a value as output.

37
New cards

What is nested function?

A nested function is a named function that is defined within another function.
let sumOfSquares x y = x*x + y*y
let square x = x * x

let sumOfSquares x y = square x + square y