1/75
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Javascript has classes.
F
Fortran matches C++ efficiency and is faster than Python.
Fortran 2008 introduced coarrays to support parallel computing.
T
C# has automatic memory management (garbage collection) and works with .NET.
T
Haskell
- functional
- domain specific
- no loops, uses recursion
- if-else guards
- very expressive mechanism for overloading
- very strong static type system
Julia has machine learning algorithms, like Python.
T
Objective-C is no longer used in the Apple IOS ecosystem.
F
Type script fixed everything.
F
Kotlin is used primarily for simple IOS games.
F
R doesn't handle large datasets well.
T
Scala is faster than Python for big data applications.
T
CMS platforms like Ghost and Django CMS are PHP-based
F
Blackbox AI systems provide clearer reasoning than Prolog.
F
Ruby on rails is a framework used for web development.
T
C uses the "*" (dereferencing) operator to return the memory address of a pointer.
F
Delphi was not built on object Pascal.
F
Batch files (.bat) can be run on Linux machines natively.
F
Ada was designed and developed by US DoD.
T
Logo was only intended to teach adults problem solving skills.
F
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)
Java is an OOP language.
T
COBOL is a purely declarative programming language.
- F
- designed for business applications
- still in use by ATMs
- Grace Hopper, government involvement
Swift falls under the functional and logic programming language paradigms, not object-oriented and protocol-oriented programming paradigms.
F
Python is a glue language.
T
Holy C uses the keyword "void" for its functions that do not return anything.
F
Lisp is one of the oldest languages used in AI.
T
BASH is a full-fledged programming language like C++.
F
Rust is a systems programming language.
T
Go does not use inheritance.
T
F# is interoperable with C# since they are both on the .NET framework.
T
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
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
benefits of functional programming
- predictability
- testability
- concurrency (concurrent and parallel execution)
- modularity
Haskell hello world
main = putStrLn "Hello World"
Haskell program example 1
main = do
putStrLn "Hello, what's your name?"
name <- getLine
putStrLn ("Hey " ++ name ++ ", yourock!")
- do binds multiple statements together
Haskell program example 2
putStrLn $ "Read this carefully, because this is your future: " ++ tellFortune name
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
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)
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)
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)
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)))
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))
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)
programs in logic languages are expressed in a form of
symbolic logic; use logical inferencing process to produce results
- declarative
proposition
logical statement that may or may not be true
- consists of objects and relationships of objects to each other
predicate calculus
particular form of symbolic logic used for logic programming
objects in propositions are represented by
- constants
- variables
constant
symbol that represents an object
variable
symbol that can represent different objects at different times (different from regular variables)
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)
propositions
- fact
- query (goal)
standard form for propositions
- clausal form
- if all As are true, at least one B is true
- antecedent: right side
- consequent: left side
unification
finding values for variables in propositions that allows matching process to succeed
instantiation
assigning temporary values to variables to allow unification to succeed
- if matching fails, may need to backtrack
T/F: theorem proving is basis for logic programming
T
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
T/F: logic programming is nonprocedural
T
matching
process of proving a proposition
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
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
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
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)
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
cons of Prolog
- resolution order control
- closed-word assumption
- negation problem
- intrinsic limitations (doesn't know how to sort)
application of logic programming
- relational database management systems
- expert systems
- natural language processing
T/F: resolution is the primary activity of a prolog interpreter.
T
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).
Prolog family tree
- brother, sister, sibling: X\=Y
structured paradigm
programming with clean, goto-free, nested control structures
- Java
procedural paradigm
imperative programming with procedure calls
- C
function-level paradigm
programming with no variables at all
- FP
event-driven
asynchronous
- javascript
flow-driven
Programming processes communicating with each other over predefined channels.
- Go
constraint
Oz
aspect-oriented
cross-cutting concerns applied transparently
- C#
reflective
programming by manipulating the program elements themselves
- Delphi
array paradigm
programming with powerful array operators that usually make loops unnecessary
- Fortran