CSc330
January 2014
Topics for Mid-Term Test #1
These are the topics covered to date and which may appear on Test #1.
Language Description & Language Implementation
compiler vs interpreter
stages of compilation
lexical analysis (scanning)
syntactic an
import math
import trapezoidalrule as trp
g = 9.8
m = 68.1
cd = 0.25
t = 10
n = 50
fn = lambda t: math.sqrt(g*m/cd) * math.tanh(math.sqrt(g*cd/m) * t)
f = trp.getxs(0,10,n)
print f
f = map(fn, f)
h = 10.0/float(n)
print h
print trp.trapm(h, n, f)
# actual
import math
# Interval: [a,b]
# Get n+1 points spaced h = (b-a)/n apart over [a,b]
# Return them in a list
def getxs(a, b, n):
h = (b-a)/float(n)
xcurr = a + h
xlist = [a]
for i in range(1,int(n+1):
xlist.append(xcurr)
xcurr += h
return xlist
# Compute re
A Simple Chess Program in Prolog
=
A. Objectives:
For this assignment, you'll learn how to use Prolog to
write recursive programs with lists and backtracking.
B. Our Problem:
There are three parts to this assignment. They are all
related.
Part I) (see the
A Simple Chess Program in Prolog
=
A. Objectives:
For this assignment, you'll learn how to use Prolog to write recursive programs with lists and backtracking.
B. Our Problem:
There are three parts to this assignment. They are all related.
Part I) (see the
move1(
move1(
move1(
move1(
move1(
move1(
move1(
move1(
(X1,Y1),
(X1,Y1),
(X1,Y1),
(X1,Y1),
(X1,Y1),
(X1,Y1),
(X1,Y1),
(X1,Y1),
up1( U, V
up2( U, W
down1( U,
down2( U,
successor(
successor(
successor(
successor(
)
)
V
V
(X2,Y2)
(X2,Y2)
(X2,Y2)
(X2,Y2)
(X2
Chess Program in PROLOG :
The main thing I learned from of this assignment is use of recursive call in PROLOG to create loops like
structure. This piece of code shows different moves of a knight on a 5x5 chessboard. The basic move
structure for going eith
edge(a,b).
edge(a,c).
edge(b,d).
edge(d,e).
edge(e,a).
edge(c,f).
edge(f,g).
edge(f,e).
path( X, Y ) :- edge( X, Y ).
path( X, Z ) :- edge( X, Y ), path( Y, Z ).
:- public( [ edge/2, path/2 ] ).
:- include( 'graph.pl' ).
%
% path(X,Y,P,N) holds if there exists a directed path P of length at most N
% from X to Y.
%
path(X,Y,[X,Y],N) :N > 0,
edge(X,Y).
path(X,Z,[X|P1],N) :N > 0,
N1 is N-1,
path(Y,Z,P1,N1),
edge(X,Y)
import trapezoidalrule as trp
from simpson13 import simpson as s13
from simpson38 import simpson as s38
import math
# function for the given table
def table1(x):
if x = 0.0:
return 1.0
elif x = 0.1:
return 8.0
elif x = 0.2:
return 4.0
elif x = 0.3:
return
import math
from simpson13 import simpson as s13
from simpson38 import simpson as s38
from trapezoidalrule import single_trap
from trapezoidalrule import relative_err
# Function for question
def table(x):
if x = 0:
return 2.0
elif x = 0.05:
return 1.8555
CSC330
Programming Languages
Parameter Passing Techniques
23 January 2014
Copying Parameter Mechanisms
Call-By-Value = Copy-In Parameter
The only parameter passing method of C; the default method for C+ and
Pascal. Used in Java for basic types, and is the
CSC330
Programming Languages
Garbage Collection:
Background
Reference Counting
Mark-Sweep
Copying Collectors
29 January 2014
History of Storage Allocation
Static allocation
a feature of Fortran (up to Fortran77)
implies sizes of arrays must be known at
CSc330
March 2014
CSC330: Assignment 4
Due: Sunday, 30 March 2014 at 11:55pm
Part 1: Practice with F# and Recursive Functions
All solutions to the following exercises must use recursion. The recursion may be hidden inside
another function as a recursive n
CSc330
February/March 2014
CSC330: Assignment 3
Due: Monday, 10 March 2014 at 11:55pm
Becoming an Expert with C# Generics
Your task is to implement a new generic collection class, much like some of those provided in the
System.Collections.Generic section
CSc330
January 2014
Assignment 1 (Due 11:55pm on Friday January 24)
Objectives
Your task is to develop a small application program (an app) using TouchDevelop. The purpose of the
assignment is mainly to force you outside your comfort zone making you use a
CSc330
January 2014
Assignment 2 (Due 01:00am Monday Feb 17)
Overview
Your task is to make a series of small changes, described below, to a C# program which consists of
six source files and totals about 1400 lines. The C# code uses a fairly rich variety o
CSc330
January 2014
Help with Task 4 of Assignment 1 (Help Document #1)
The TouchDevelop API does not provide any way to discover what obstacles have been placed on a
gameboard, to remove obstacles, or to access or change properties of obstacles.
Therefor
CSc330
Programming Languages
Spring Term 2014
University of Victoria
Department of Computer Science
CSC330: Programming Languages
Introduction: Slide 1
Where to find things
Instructor
Nigel Horspool
Contact Info
nigelh@uvic.ca
ECS 520
Official Course Outl
Specifying Programming
Language Syntax
CSc330
Notice the regular expression
9 January 2014
Specifying Lexical Structure
The individual language elements are usually specified using Regular Expressions.
The formal R.E. notation is defined as follows.
A RE
Programming Language
Implementation:
Compilation vs Interpretation
CSc330
7 January 2014
Compilation vs Interpretation
Compilation
Source files are checked for errors and translated (compiled) into executable files (which contain
binary machine instructio
Getting Started with
TouchDevelop
CSc330
7 January 2014
TouchDevelop (TD) Introduction
Originally created as a scripting language for the Windows phone, where scripts could be
developed on the phone itself. The script + TD = an app for the phone.
The smal