CS135

studied byStudied by 1 person
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 / 38

encourage image

There's no tags or description

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

39 Terms

1

What is Computation?

Have instructions that the computer has to complete

New cards
2

Imperative Design

Based on frequent changes to data

e.x, Java, C++, Python

New cards
3

Functional Design

Computation of new vales rather than the transformation of old ones

e.x, Excel formula, XSLT, LISP

New cards
4

Syntax

How things are supposed to be said

e.x, “?is This Sentence syntactically correct”

New cards
5

Semantics

What the actual meaning is

e.x, “Trombones fly hungrily”

New cards
6

Ambiguity

Valid programs have exactly one meaning

e.x, “Sally was given a book by Joce”

New cards
7

Values

Numbers or mathematical objects (5, 4/9, pi)

New cards
8

Expression

Combine values with operators and functions

E.x, (5+2)

New cards
9

Functions

Generalize similar expressions

E.x, f(x)= x²+4x+2

New cards
10

Different components of a function

  1. Name of function (g)

  2. Parameters (x y)

  3. Algebraic expression using parameters

New cards
11

Arguments

Supplies arguments for parameters

New cards
12

Infix

(+, -, et.c)

E.x, 3-2 = (- 3 2)

(6-4) / (5+7) = / ((- 6 4) (+ 5 7))

New cards
13

Yield Symbol

Each step is indicated using “Yield Symbol”

New cards
14

Ellipses

Use ellipses to show a pattern

(f v1 v2 v3) = V

New cards
15

Defining Functions

“Binds name to body”

(define(g x y) (+ x y))

New cards
16

Syntax Error

Reading an expression

New cards
17

Run-Time error

Evaluating an expression

25/0 cannot work

New cards
18

Substitution Rule

New cards
19

Identifiers

Functions named by identifiers (e.x, x-ray)

New cards
20

Observations

Parameter order matters

(define (g x y) (- x y)

DOES NOT =

(define (g y x) (- x y)

New cards
21

Constants

k=3, p=k²

(define k 3)

(define p (sqr k)) = ‘p’ gets bound to the new value

  • Are used in any expression (body of a function)

  • Don’t repeat a definition once its expression has been reduced to a value

New cards
22

Comments

;

;; Comments which use whole line

(+ 6 7) ; Comment after code (use one semi-colon

New cards
23

Block Comments

#|

(define (function-to-temporarily-remove x y)

(+ x y))

|#

New cards
24

Helper Function

Help implement another function

  • Helper used to define constants must be defined before

    - (define c (distance 1 1 3 9))

New cards
25

Check-expert

Form that we use to test function

(check-expert expr-test expr-expected)

  • expr-test = function application we are testing

  • expr-expected = expected result “correct answer”

New cards
26

Scope

Global & Function

  • The Scope of an identifier is where it has effect (in program)

    1. Smallest enclosing scope has priority

    2. Duplicate identifiers within the same scope will cause an error

(define f 3)

(define (fx)(sqr x))

*ERROR - WAS ALREADY DEFINED

New cards
27

Booleans

(< x 5)

T or F value

<, >, >=, <=, = [each produces a value]

  • Abbreviated Bool

New cards
28

Predicates

Function that produces a bool is a ‘predicate’

  • Usually has a ‘?’ at the end

  • (can-vote? age)

New cards
29

Combining Predicates

and, or, not all consume and produce Bool values

New cards
30

Substitution Rules (and)

(and false …) = false

(and true) = (and …)

(and) = true

New cards
31

Substitution Rules (or)

(or true …) = true

(or false …) = (or …)

(or) = false

New cards
32

Conditional expressions

Expressions should take one value under certain conditions (cond)

  • Question is Boolean

  • Answer is a possible value of the conditional expression

New cards
33

Short-Circuit Evaluation

Evaluates as many arguments of (and) & (or) that is necessary to find final result

New cards
34

else

If none of the conditions were satisfied, then we do something else

New cards
35

Nested Conditions

Nests one conditional expression inside another

New cards
36

Flattening Nested Conditions

Flats the condition to make it easier to read than nested

  • No cond with another cond inside (see notes for example)

[else (cond… *THIS HAS TO BE FLATTEND

New cards
37

Bounding Conditions

  • Cut off between passing and failing

New cards
38
<p>Intervals for testing </p>

Intervals for testing

New cards
39
<p>RULES OF SUBSITIUTION  </p>

RULES OF SUBSITIUTION

New cards

Explore top notes

note Note
studied byStudied by 3 people
146 days ago
5.0(1)
note Note
studied byStudied by 8 people
674 days ago
5.0(1)
note Note
studied byStudied by 2599 people
305 days ago
5.0(11)
note Note
studied byStudied by 73 people
703 days ago
5.0(2)
note Note
studied byStudied by 29 people
777 days ago
5.0(3)
note Note
studied byStudied by 20 people
730 days ago
5.0(1)
note Note
studied byStudied by 5 people
640 days ago
5.0(1)

Explore top flashcards

flashcards Flashcard (20)
studied byStudied by 9 people
759 days ago
5.0(4)
flashcards Flashcard (68)
studied byStudied by 44 people
366 days ago
5.0(1)
flashcards Flashcard (67)
studied byStudied by 3 people
735 days ago
5.0(1)
flashcards Flashcard (46)
studied byStudied by 4 people
823 days ago
5.0(1)
flashcards Flashcard (61)
studied byStudied by 5 people
399 days ago
5.0(1)
flashcards Flashcard (34)
studied byStudied by 33 people
153 days ago
5.0(1)
flashcards Flashcard (39)
studied byStudied by 2 people
89 days ago
5.0(1)
flashcards Flashcard (314)
studied byStudied by 1 person
46 minutes ago
5.0(1)
robot