Let 2. Abstractions

studied byStudied by 6 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 36

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

37 Terms

1

What is programming?

Programming is the process of creating a program.

New cards
2

What do you represent a program?

We represent a program with a language(programming language)

New cards
3

What are high-level languages?

F#, Haskell, Skala

New cards
4

What are low-level languages?

Assembly language

New cards
5

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

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

New cards
6

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

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

New cards
7

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).

New cards
8

What does good programming language do?

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

New cards
9

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.

New cards
10

What is a program?

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

New cards
11

What do we use to represent computations?

Functions

New cards
12

What do we build abstractions and manipulate data with?

Functions

New cards
13

What is imperative programming?

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

New cards
14

What is functional programming?

Functional programming is all about writing down functions denoting values.

New cards
15

What do we call functional programming as?

Value-oriented programming.

New cards
16

What is the basic building block for programs?

Expressions

New cards
17

What is expression?

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

New cards
18

What is semantics?

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

New cards
19

When do we say a program is well-typed?

When all expression in the program satisfy the type constraints.

New cards
20

What does expression have?

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

New cards
21

What does evaluation of an expression fail?

When the type checking fails.

New cards
22

What is a function?

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

New cards
23

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

New cards
24

Does function application need parentheses?

Function applications typically do not require parentheses in F#.

New cards
25

What id REPL?

Read-Evaluate-Print Loop.

New cards
26

A REPL for F# is…

fsi (or fsharpi).

New cards
27

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

In a special identifier, called “it”.

New cards
28

What do we use to indicate type of expression?

colon ()

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

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.

New cards
30

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>
New cards
31

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>
New cards
32

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>
New cards
33

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>
New cards
34

Nested functions

knowt flashcard image
New cards
35

Evaluation rule?

knowt flashcard image
New cards
36

What is evaluation?

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

New cards
37

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

New cards
robot