Functional Programming Examples: Recursion, Streams, and More

Bisection Method & Polynomial Root Finding

fun bisection (f,a,b) =
let val mid = (a+b) / 2.0 in
if Math.abs (a-b) < 0.00001 then mid
else
if (f mid) * (f a) < 0.0 then bisection (f,a,mid)
else bisection (f,mid,b)
fun mypoly x = x*x*x -7
val root = bisection (mypoly, 6.0, 0.0, 7.0)

Cube and Sum of Cubes

fun cube a = a*a*a
fun sumCubes (a,b) =
if (a>b) then 0 else cube (a) + sumCubes (a+1,b)

Tree Traversal and Filtering

fun gather (p : int -> bool) (T : string tree)

Read More

Understanding Computer Systems: A Deep Dive into Operating Systems, Memory Management, and Assembly Language

1. For the following questions circle True or False The operating system has the power to suspend your program when it is running. TRUE FALSE The only reason the operating system is “special” is because it is the first program Loaded. TRUE FALSE In a time sharing system multiple process take turns running on the CPU. TRUE FALSE Caches would work well for a program that randomly accesses locations in memory.
TRUE FALSE An an Interrupt Drive I/O system the hardware is responsible for doing all

Read More

Introduction to Programming with Python: Fundamentals and Data Structures

Programming Languages

Programs are found in many places such as on your computer, your cell phone, or on the internet. A program is a set of instructions that are run or executed. There are many programming languages and, for this course, we will use the Python programming language.

Arithmetic Operators

Operator

Operation

Expression

English description

Result

+

Addition

11 + 56

11 plus 56

67

Subtraction

23 – 52

23 minus 52


-29

Multiplication

4 * 5

4 multiplied by 5

20

Exponentiation

2 ** 5

2 to the power of 5

32

/

division

9

Read More

Python Programming Fundamentals: Introduction to Data Types, Operators, and Control Flow

Programming Languages

Programs are found in many places such as on your computer, your cell phone, or on the internet. A program is a set of instructions that are run or executed. There are many programming languages and, for this course, we will use the Python programming language.

Arithmetic Operators

Operator

Operation

Expression

English description

Result

+

Addition

11 + 56

11 plus 56

67

Subtraction

23 – 52

23 minus 52


-29

Multiplication

4 * 5

4 multiplied by 5

20

Exponentiation

2 ** 5

2 to the power of 5

32

/

division

9

Read More

Software Engineering Fundamentals and Methodologies

CH1


SW prods: 1.Generic: The spec.
Of wht the SW shud do is owned by the SW dever & decisions on SW chnge r made by the dever. 2. Cus2mized: The spec. Of wht the SW shud do is owned by the cstmr
4 the SW & they make decisions on SW chnges that r reqd. SW: Computer progs & associated docmn.. SW prods may b deved 4 a particular cstmr or may b deved 4 a general market. Attributes of good SW: deliver the reqd funcnality & per4mance, maintainable, dependable & usable.SE: engi. Discipline

Read More

Recursive and Iterative Drawing in Python with Turtle

Homework 2

DrawStar(S, N)

Recursion to draw snowflake

python def DrawStar(S, N): """ Recursion to draw snowflake """ if N == 1: pass else: turtle.forward(S/3) DrawStar(S/3, N-1) turtle.forward(-S/3) turtle.left(60) turtle.forward(S/3) DrawStar(S/3, N-1) turtle.forward(-S/3) turtle.left(60) turtle.forward(S/3) DrawStar(S/3, N-1) turtle.forward(-S/3) turtle.left(120) turtle.forward(S/3) DrawStar(S/3, N-1) turtle.forward(-S/3) turtle.left(60) turtle.forward(S/3) DrawStar(S/3, N-1) turtle.forward(-S/3)

Read More