Programming Languages Exam 4

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
GameKnowt Play
New
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/75

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.

76 Terms

1
New cards

Javascript has classes.

F

2
New cards

Fortran matches C++ efficiency and is faster than Python.

Fortran 2008 introduced coarrays to support parallel computing.

T

3
New cards

C# has automatic memory management (garbage collection) and works with .NET.

T

4
New cards

Haskell

- functional

- domain specific

- no loops, uses recursion

- if-else guards

- very expressive mechanism for overloading

- very strong static type system

5
New cards

Julia has machine learning algorithms, like Python.

T

6
New cards

Objective-C is no longer used in the Apple IOS ecosystem.

F

7
New cards

Type script fixed everything.

F

8
New cards

Kotlin is used primarily for simple IOS games.

F

9
New cards

R doesn't handle large datasets well.

T

10
New cards

Scala is faster than Python for big data applications.

T

11
New cards

CMS platforms like Ghost and Django CMS are PHP-based

F

12
New cards

Blackbox AI systems provide clearer reasoning than Prolog.

F

13
New cards

Ruby on rails is a framework used for web development.

T

14
New cards

C uses the "*" (dereferencing) operator to return the memory address of a pointer.

F

15
New cards

Delphi was not built on object Pascal.

F

16
New cards

Batch files (.bat) can be run on Linux machines natively.

F

17
New cards

Ada was designed and developed by US DoD.

T

18
New cards

Logo was only intended to teach adults problem solving skills.

F

19
New cards

Dart

- JIT compilation

- used to develop web and mobile apps

- OOP, class-based, garbage-collected language with C-style syntax

- Dart has replaced JavaScript in web development and the Dart VM has replaced the JavaScript engine in all major browsers (F)

20
New cards

Java is an OOP language.

T

21
New cards

COBOL is a purely declarative programming language.

- F

- designed for business applications

- still in use by ATMs

- Grace Hopper, government involvement

22
New cards

Swift falls under the functional and logic programming language paradigms, not object-oriented and protocol-oriented programming paradigms.

F

23
New cards

Python is a glue language.

T

24
New cards

Holy C uses the keyword "void" for its functions that do not return anything.

F

25
New cards

Lisp is one of the oldest languages used in AI.

T

26
New cards

BASH is a full-fledged programming language like C++.

F

27
New cards

Rust is a systems programming language.

T

28
New cards

Go does not use inheritance.

T

29
New cards

F# is interoperable with C# since they are both on the .NET framework.

T

30
New cards

functional programming

programming paradigm that treats computations as the evaluation of mathematical functions and avoids changing state and mutable data, focusing on pure functions and immutability

31
New cards

key principles of functional programming

- pure functions: functions that take input and produce output, without any side effects or modifying external state; same input always produces same output

- immutability

- first-class functions: functions treated as any other data type

- higher-order functions: functions take other functions as args or return functions as results

- referential transparency: a function can be replaced by its value without changing the program's behavior

- recursion: solving problem with smaller, similar subprograms

- function composition: combining multiple functions to create more complex functions

32
New cards

benefits of functional programming

- predictability

- testability

- concurrency (concurrent and parallel execution)

- modularity

33
New cards

Haskell hello world

main = putStrLn "Hello World"

34
New cards

Haskell program example 1

main = do

putStrLn "Hello, what's your name?"

name <- getLine

putStrLn ("Hey " ++ name ++ ", yourock!")

- do binds multiple statements together

35
New cards

Haskell program example 2

putStrLn $ "Read this carefully, because this is your future: " ++ tellFortune name

36
New cards

T/F: This line of Haskell code is valid.

nameTag = "Hello, my name is " ++ getLine

F; ++ requires both its parameters to be lists over the same type

- left param is type String, getLine is type IO String

37
New cards

Haskell program example 3

- Function to compute 3x + 5

calculate :: Int -> Int

calculate x = 3 * x + 5

main = do

putStrLn "Enter an integer:"

input <- getLine

let number = read input :: Int

let result = calculate number

putStrLn ("Result: " ++ show result)

38
New cards

Haskell program example 4

lucky :: (Integral a) => a -> String

lucky 7 = "LUCKY NUMBER SEVEN!"

lucky x = "Sorry, you're out of luck, pal!"

main = do

putStrLn "Enter an integer:"

input <- getLine

let number = read input :: Int

let result = lucky number

putStrLn ("Result: " ++ show result)

39
New cards

Haskell using recursion

factorial :: (Integral a) => a -> a

factorial 0 = 1

factorial n = n * factorial (n - 1)

main = do

putStrLn "Enter an integer:"

input <- getLine

let number = read input :: Int

let result = factorial number

putStrLn ("Result: " ++ show result)

40
New cards

Haskell program example 5

main = do

putStrLn "Enter an integer:"

input <- getLine

let number = read input :: Int

putStrLn ("number: " ++ show number)

putStrLn ("succ: " ++ show (succ number))

putStrLn ("succ succ: " ++ show (succ (succ number)))

41
New cards

Haskell program ex. 6

-- else part is mandatory with if statement in Haskell

doubleSmallNumber x = if x > 100

then x

else x*2

main = do

putStrLn "Enter an integer:"

input <- getLine

let number = read input :: Int

putStrLn ("doubleSmallNumber result: " ++ show (doubleSmallNumber number))

42
New cards

Haskell program ex. 7

main = do

let a = [3,4,5,6]

putStrLn("list a is " ++ show a)

let b = [97,98,99]

putStrLn("list b is " ++ show b)

let c = a ++ b

putStrLn("list c is " ++ show c)

-- : is the cons operator for Haskell - combine an item with a list

let d = 22:c

putStrLn("list d is " ++ show d)

-- !! is used to return the element at a given index (starting at zero)

let e = a!!2

putStrLn("element e is " ++ show e)

43
New cards

programs in logic languages are expressed in a form of

symbolic logic; use logical inferencing process to produce results

- declarative

44
New cards

proposition

logical statement that may or may not be true

- consists of objects and relationships of objects to each other

45
New cards

predicate calculus

particular form of symbolic logic used for logic programming

46
New cards

objects in propositions are represented by

- constants

- variables

47
New cards

constant

symbol that represents an object

48
New cards

variable

symbol that can represent different objects at different times (different from regular variables)

49
New cards

atomic propositions consist of

compound terms: one element of a mathematical relation, written like a mathematical function

- mapping

- can be written as table

- composed of two parts: functor: function symbol that names relation

ordered list of parameters(tuple)

50
New cards

propositions

- fact

- query (goal)

51
New cards

standard form for propositions

- clausal form

- if all As are true, at least one B is true

- antecedent: right side

- consequent: left side

52
New cards

unification

finding values for variables in propositions that allows matching process to succeed

53
New cards

instantiation

assigning temporary values to variables to allow unification to succeed

- if matching fails, may need to backtrack

54
New cards

T/F: theorem proving is basis for logic programming

T

55
New cards

horn clause

can have only two forms

- headed: single atomic preposition on left side

ex. rule statements

ancestor(mary, shelley) :- mother(mary, shelley).

parent(X,Y):- mother(X,Y).

parent(X,Y):- father(X,Y).

grandparent(X,Z):- parent(X,Y), parent(Y,Z).

- headless: empty left side (used to state facts)

ex. female(shelley).

father(bill, jake).

- most propositions can be stated as horn clauses

56
New cards

T/F: logic programming is nonprocedural

T

57
New cards

matching

process of proving a proposition

58
New cards

bottom-up resolution, forward chaining

begin with facts and rules of database and attempt to find sequence that leads to goal.

- works well with large set of possibly correct answeres

59
New cards

top-down resolution, backward chaining

begin with goal and attempt to find sequence that leads to set of facts in database

- works well with small set of possibly correct answers

- Prolog uses this

60
New cards

When goal has more than one subgoal, can use either

- depth first search: find complete proof for first subgoal before working on others (Prolog; done with fewer computer resources)

- breadth-first search: work on all subgoals in parallel

61
New cards

tracing model of execution - 4 events

- call (beginning of attempt to satisfy goal)

- exit (when a goal has been satisfied)

- redo (when backtrack occurs)

- fail (when goal fails)

62
New cards

tracing example

likes(jake,chocolate).

likes(jake, apricots).

likes(darcie, licorice).

likes(darcie, apricots).

trace.

likes(jake, X), likes(darcie, X).

(1) 1 Call: likes(jake, _0)?

(1) 1 Exit: likes(jake, chocolate)(2) 1 Call: likes(darcie, chocolate)?

(2) 1 Fail: likes(darcie, chocolate)

(1) 1 Redo: likes(jake, _0)?

(1) 1 Exit: likes(jake, apricots)

(3) 1 Call: likes(darcie, apricots)?

(3) 1 Exit: likes(darcie, apricots)

X = apricots

63
New cards

cons of Prolog

- resolution order control

- closed-word assumption

- negation problem

- intrinsic limitations (doesn't know how to sort)

64
New cards

application of logic programming

- relational database management systems

- expert systems

- natural language processing

65
New cards

T/F: resolution is the primary activity of a prolog interpreter.

T

66
New cards

Prolog classification of animals program

- make facts at lowest level

ex. mammal(bear).

mammal(tiger).

mammal(whale).

- make rules at levels above:

warmBlooded(X) :- mammal(X).

warmBlooded(X) :- mammal(X).

vertebrate(X) :- warmBlooded(X).

animal(X) :- vertebrate(X).

67
New cards

Prolog family tree

- brother, sister, sibling: X\=Y

68
New cards

structured paradigm

programming with clean, goto-free, nested control structures

- Java

69
New cards

procedural paradigm

imperative programming with procedure calls

- C

70
New cards

function-level paradigm

programming with no variables at all

- FP

71
New cards

event-driven

asynchronous

- javascript

72
New cards

flow-driven

Programming processes communicating with each other over predefined channels.

- Go

73
New cards

constraint

Oz

74
New cards

aspect-oriented

cross-cutting concerns applied transparently

- C#

75
New cards

reflective

programming by manipulating the program elements themselves

- Delphi

76
New cards

array paradigm

programming with powerful array operators that usually make loops unnecessary

- Fortran