Fri Dec 15 -
Last few seconds of the final exam with Mr. Biao Feng and dgerman.
So long, everybody!
Wed Dec 06 -
The end of the beginning: here.
Tue Dec 05 -
A link for Aaron.
Mon Dec 04 -
What we discussed in class today: here.
Fri Dec 01 -
Lab today will help you with the first 12 problems on the final.
Lab next week will help you with the next 12 questions on the final.
Thu Nov 30 -
Why we practice self-assessment after each exam:
"Critical thinking is thinking that assesses itself.
To the extent that our students need us to tell them how well they are doing, they are not thinking
critically. Didactic instruction makes students overly dependent on the teacher. In such instruction, students
rarely develop any perceptible intellectual independence and typically have no intellectual standards to
assess their thinking with. Instruction that fosters a disciplined, thinking mind, on the other hand, is 180
degrees in the opposite direction. [...]" (Read more).
Why there is no curve in this class:
We hold these truths to be self-evident: (a) That all
students are intrinsically motivated to learn but learn to be
unmotivated if they repeatedly fail; (b) That every student has the
basic needs to belong, to be competent and to influence what happens to
them; motivation to learn only exists when these three conditions are satisfied;
(c) Learning is hard, expensive (in terms of effort) and involves taking
risks, so it is imperative that students need to perceive the classroom
as a safe environment both from a physical and psychological
perspective. Finally, and this is in fact the crux of the matter here and in
the rest of higher-education, high
self-esteem should not be a goal, but
rather a result (or a
consequence), that comes with the mastery of challenging
tasks.
We will never curve your scores artificially (either higher or lower).
But we will always allow you to make up exams and assignments to score
as high as you can in this class. We will never artificially inflate
performance (out of respect for you and ourselves) and we will always
provide opportunities to show you have grown into a more effective and
skilled programmer and problem-solver.
Wed Nov 29 -
What we did in class today.
The final version.
Here's how you run it:
-bash-4.2$ node exercise.js
I am starting.
I am retrieving state.
I need to initialize.
Initialize state.
Here I am.
QuizState { message: 'Welcome', n1: 57, n2: 95, m1: 0, m2: 0 }
Welcome
102
you entered: [102]
I am starting.
I am retrieving state.
I need to update...
No, 57 + 95 != 102
QuizState { message: '(0/1) 45 + 81 = ... ', n1: 45, n2: 81, m1: 0, m2: 1 }
(0/1) 45 + 81 = ...
126
you entered: [126]
I am starting.
I am retrieving state.
I need to update...
Yes, 45 + 81 = 126
QuizState { message: '(1/2) 54 + 4 = ... ', n1: 54, n2: 4, m1: 1, m2: 2 }
(1/2) 54 + 4 = ...
58
you entered: [58]
I am starting.
I am retrieving state.
I need to update...
Yes, 54 + 4 = 58
QuizState { message: '(2/3) 78 + 18 = ... ', n1: 78, n2: 18, m1: 2, m2: 3 }
(2/3) 78 + 18 = ...
100
you entered: [100]
I am starting.
I am retrieving state.
I need to update...
No, 78 + 18 != 100
QuizState { message: '(2/4) 41 + 7 = ... ', n1: 41, n2: 7, m1: 2, m2: 4 }
(2/4) 41 + 7 = ...
-bash-4.2$ pwd
/u/dgerman/apache/htdocs/a202/fall2017/11292017
Tue Nov 28 -
From Keeghan for whoever wants to keep MongoDB up and running in the background:
nohup numactl --interleave=all mongod -port 42792 --dbpath documents --fork --logpath mongo.log
Tue Nov 28 -
Here's your
final exam.
The exam is take home, please turn it in in person, at your convenience.
Mon Nov 27 -
We're discussing Homework 09 in class today.
Fri Nov 24 -
A report on what web development is and should be.
Thu Nov 23 -
Additional information about the broad scope of our language.
Wed Nov 22 -
Here's an increasingly popular alternative to Angular:
[1],
[2].
Tue Nov 21 -
Here's an update on our Angular resources.
Mon Nov 20 -
I am grading
your exams and will
post scores soon.
Sun Nov 19 - Thanksgiving Break starts.
Sat Nov 18 - In OH (Gambier and Canton) today.
Fri Nov 17 -
Here's the plan for today's lab (for those who make it to PV151).
The title of the lab is: Alternative Default Project(s).
The idea is that there's more than one way to do a similar kind of project.
Here are the steps to consider:
- Access this book from your reading packet.
- Open at Chapter 28. Decide on two distinct ports.
- Assume your HTTP server port is
31241 .
- Further assume your MongoDB port is
31242 .
- Go to
a202-workspace create folder thanksgiving .
- Go into the folder and bring in the code archive:
-bash-4.2$ cd a202-workspace/
-bash-4.2$ mkdir thanksgiving
-bash-4.2$ cd thanksgiving/
-bash-4.2$ pwd
/u/dgerman/a202-workspace/thanksgiving
bash-4.2$ cp /l/www/classes/a348/fall2014/sample-code/nodejs-mongodb-angularjs-web-development-master.zip .
-bash-4.2$ ls -l
total 8128
-rw-r--r-- 1 dgerman faculty 6088678 Nov 17 10:07 nodejs-mongodb-angularjs-web-development-master.zip
-bash-4.2$ unzip nodejs-mongodb-angularjs-web-development-master.zip
[...]
-bash-4.2$
-bash-4.2$ pwd
/u/dgerman/a202-workspace/thanksgiving
-bash-4.2$ ls -l
total 5952
drwxr-xr-x 31 dgerman faculty 4096 Oct 31 2014 nodejs-mongodb-angularjs-web-development-master
-rw-r--r-- 1 dgerman faculty 6088678 Nov 17 10:07 nodejs-mongodb-angularjs-web-development-master.zip
-bash-4.2$ rm nodejs-mongodb-angularjs-web-development-master.zip
-bash-4.2$ ls -l
total 4
drwxr-xr-x 31 dgerman faculty 4096 Oct 31 2014 nodejs-mongodb-angularjs-web-development-master
-bash-4.2$ cd nodejs-mongodb-angularjs-web-development-master/
-bash-4.2$ ls
ch03 ch05 ch07 ch09 ch13 ch15 ch17 ch19 ch21 ch23 ch25 ch26-google-auth ch28 images node_modules
ch04 ch06 ch08 ch10 ch14 ch16 ch18 ch20 ch22 ch24 ch26 ch27 ch29 lib README.md
-bash-4.2$
Do you understand what happened here? If so go into ch28 folder.
- Look at the code in the folder:
-bash-4.2$ pwd
/u/dgerman/a202-workspace/thanksgiving/nodejs-mongodb-angularjs-web-development-master/ch28
-bash-4.2$ ls -l
total 16
-rw-r--r-- 1 dgerman faculty 2708 Oct 31 2014 cart_init.js
-rw-r--r-- 1 dgerman faculty 860 Oct 31 2014 cart_routes.js
-rw-r--r-- 1 dgerman faculty 467 Oct 31 2014 cart_server.js
drwxr-xr-x 2 dgerman faculty 108 Oct 31 2014 controllers
drwxr-xr-x 2 dgerman faculty 34 Oct 31 2014 models
drwxr-xr-x 4 dgerman faculty 4096 Oct 31 2014 static
drwxr-xr-x 2 dgerman faculty 34 Oct 31 2014 views
-bash-4.2$
- Update
cart_init.js and cart_server.js .
- Go to a different folder and start your MongoDB (
mongodb ) server.
- Separately connect with
mongo to the database server.
- Run
cart_init.js (get out of it with ^C if needed).
- Check (
mongo ) that your database has been initialized/populated.
- Start your HTTP server (
node cart_server.js ).
- Access your server online (
http://silo.cs.indiana.edu:31241 )
- Select some items for purchase, go through all stages, submit order.
- Verify the order has been placed in the database (
mongo command line).
This is the first Shopping Cart program we have shown in this class.
Look through the book it has info on Node, Express, Mongo and Angular (the whole stack).
Some of the commands you might use from mongo prompt:
-bash-4.2$ mongo silo.cs.indiana.edu:31242
MongoDB shell version: 2.6.12
connecting to: silo.cs.indiana.edu:31242/test
> show dbs
admin (empty)
cart 0.078GB
local 0.078GB
> use cart
switched to db cart
> show collections
customers
orders
products
system.indexes
> var customers = db.getCollection("customers");
> customers.find()
{ "_id" : ObjectId("5a0e75f3d863a4b7d247dc41"), "userid" : "customerA", "cart" : [ ], "billing" : [ { "expireyear" : 2020, "expiremonth" : 1, "number" : "1234567890", "name" : "Customer A", "cardtype" : "Visa", "address" : [ { "zip" : "55555", "state" : "CA", "city" : "My Town", "address" : "Somewhere", "name" : "Customer A" } ] } ], "shipping" : [ { "zip" : "55555", "state" : "CA", "city" : "My Town", "address" : "Somewhere", "name" : "Customer A" } ], "__v" : 0 }
> var orders = db.getCollection("orders");
> orders.find()
{ "_id" : ObjectId("5a0e75f3d863a4b7d247dc42"), "userid" : "customerA", "timestamp" : ISODate("2017-11-17T05:38:59.934Z"), "status" : "Pending", "billing" : [ { "expireyear" : 2020, "expiremonth" : 1, "number" : "1234567890", "name" : "Customer A", "cardtype" : "Visa", "address" : [ { "zip" : "55555", "state" : "CA", "city" : "My Town", "address" : "Somewhere", "name" : "Customer A" } ] } ], "shipping" : [ { "zip" : "55555", "state" : "CA", "city" : "My Town", "address" : "Somewhere", "name" : "Customer A" } ], "items" : [ { "quantity" : 1, "product" : [ { "_id" : ObjectId("5a0e75f3d863a4b7d247dc43"), "instock" : 4, "description" : "View of the breathtaking Delicate Arch in Utah", "price" : 12.34, "imagefile" : "arch.jpg", "name" : "Delicate Arch Print", "__v" : 0 } ] }, { "quantity" : 1, "product" : [ { "_id" : ObjectId("5a0e75f3d863a4b7d247dc44"), "instock" : 4, "description" : "View of a tropical lake backset by a volcano", "price" : 45.45, "imagefile" : "volcano.jpg", "name" : "Volcano Print", "__v" : 0 } ] }, { "quantity" : 1, "product" : [ { "_id" : ObjectId("5a0e75f3d863a4b7d247dc45"), "instock" : 5, "description" : "Look at the amazing architecture of early America.", "price" : 38.52, "imagefile" : "pyramid.jpg", "name" : "Tikal Structure Print", "__v" : 0 } ] }, { "quantity" : 1, "product" : [ { "_id" : ObjectId("5a0e75f3d863a4b7d247dc46"), "instock" : 10, "description" : "Vivid color, crystal clear water from glacial runoff.", "price" : 77.45, "imagefile" : "lake.jpg", "name" : "Glacial Lake Print", "__v" : 0 } ] } ], "__v" : 4 }
{ "_id" : ObjectId("5a0e762900a677cad2aedc55"), "userid" : "customerA", "timestamp" : ISODate("2017-11-17T05:39:53.985Z"), "status" : "Pending", "billing" : [ { "address" : [ ] } ], "shipping" : [ null ], "items" : [ { "quantity" : 2, "product" : [ { "_id" : ObjectId("5a0e75f3d863a4b7d247dc43"), "name" : "Delicate Arch Print", "imagefile" : "arch.jpg", "price" : 12.34, "description" : "View of the breathtaking Delicate Arch in Utah", "instock" : 4, "__v" : 0 } ] } ], "__v" : 0 }
{ "_id" : ObjectId("5a0e764500a677cad2aedc56"), "userid" : "customerA", "timestamp" : ISODate("2017-11-17T05:40:21.954Z"), "status" : "Pending", "billing" : [ { "address" : [ ] } ], "shipping" : [ null ], "items" : [ { "quantity" : 1, "product" : [ { "_id" : ObjectId("5a0e75f3d863a4b7d247dc45"), "name" : "Tikal Structure Print", "imagefile" : "pyramid.jpg", "price" : 38.52, "description" : "Look at the amazing architecture of early America.", "instock" : 5, "__v" : 0 } ] } ], "__v" : 0 }
{ "_id" : ObjectId("5a0e766200a677cad2aedc57"), "userid" : "customerA", "timestamp" : ISODate("2017-11-17T05:40:50.243Z"), "status" : "Pending", "billing" : [ { "address" : [ ] } ], "shipping" : [ null ], "items" : [ { "quantity" : 12, "product" : [ { "_id" : ObjectId("5a0e75f3d863a4b7d247dc45"), "instock" : 5, "description" : "Look at the amazing architecture of early America.", "price" : 38.52, "imagefile" : "pyramid.jpg", "name" : "Tikal Structure Print", "__v" : 0 } ] } ], "__v" : 0 }
> var products = db.getCollection("products");
> products.find()
{ "_id" : ObjectId("5a0e75f3d863a4b7d247dc43"), "name" : "Delicate Arch Print", "imagefile" : "arch.jpg", "price" : 12.34, "description" : "View of the breathtaking Delicate Arch in Utah", "instock" : 4, "__v" : 0 }
{ "_id" : ObjectId("5a0e75f3d863a4b7d247dc44"), "name" : "Volcano Print", "imagefile" : "volcano.jpg", "price" : 45.45, "description" : "View of a tropical lake backset by a volcano", "instock" : 4, "__v" : 0 }
{ "_id" : ObjectId("5a0e75f3d863a4b7d247dc45"), "name" : "Tikal Structure Print", "imagefile" : "pyramid.jpg", "price" : 38.52, "description" : "Look at the amazing architecture of early America.", "instock" : 5, "__v" : 0 }
{ "_id" : ObjectId("5a0e75f3d863a4b7d247dc46"), "name" : "Glacial Lake Print", "imagefile" : "lake.jpg", "price" : 77.45, "description" : "Vivid color, crystal clear water from glacial runoff.", "instock" : 10, "__v" : 0 }
> exit
bye
-bash-4.2$
Wed Nov 15 -
Notes as we wrote them in class today in real time.
Tue Nov 14 -
Notes as we wrote them in class yesterday in real time.
Mon Nov 13 -
Some resources for the default semester project.
Sat-Sun Nov 11-12 -
Some links to discuss on Monday:
- Holmes (2nd edition)
- Cantelon et al. (2nd edition)
- Holmes (1st edition)
- Young/Harter
We're going to discuss other resources as well in class.
Fri Nov 10 -
Exam 03 in lab today.
Wed Nov 08 -
Here's a study guide for Exam 03: here.
Here's the sequence of steps in Homework 10: here.
Mon Nov 06 -
Notes as we wrote them in class today in real time.
Fri Nov 03 -
Here's the text I promised.
Thu Nov 02 -
I need this again today.
Wed Nov 01 -
Notes as we wrote them in class today in real time.
Tue Oct 31 -
The lab this week: chapter 8 in this book.
Mon Oct 30 -
Notes as we wrote them in class today in real time.
Wed Oct 25 -
Notes as we wrote them in class today in real time.
Tue Oct 24 -
Here's the finished example for Homework 07.
Here's how it looks:

Clearly, I forgot to scale the width of the line, too.
Mon Oct 23 -
Here is some help with Homework 08.
Notes as we wrote them in class today in real time.
Sat-Sun Oct 21-22 -
Some help with the drawing assignment: cat, cats.
Drawings not scalable, though; that would be the last part.
This was our model, by the way:

Wed Oct 18 -
Notes as we wrote them in class today in real time.
Mon Oct 16 -
Notes as we wrote them in class today in real time.
Sun Oct 15 -
Link:
http://jsfiddle.net/m1erickson/Ud7R3/
Wed Oct 11 -
Midterm Exam in class today: what it looked like.
Mon Oct 09 -
Though painfully slow, we managed to sketch a draft for your midterm study guide.
Thu-Sun Oct 05-08 -
Fall Break starts on Friday (no labs on Friday).
Wed Oct 04 -
Notes as we wrote them in class today in real time.
Tue Oct 03 -
Some things to look at tomorrow in class:
There's more, and we will bring things up as needed in class.
Mon Oct 02 -
Notes as we wrote them in class today in real time.
Sun Oct 01 -
Some challenges for tomorrow:
- random pictures (in order)
- random pictures (entirely random)
- addition quiz (framework?)
Let's work at least one in class tomorrow.
Wed Sep 27 -
Notes as we wrote them in class today in real time.
Tue Sep 26 -
Tomorrow in class we are going to look at this:
Mon Sep 25 -
Notes as we wrote them in class today in real time.
Sun Sep 24 -
What does the following tell us?
[beixlei@silo 11162016]$ cat convert.js
// " ( ( ( 3 - 2 ) + 2 ) / ( ( 1 + 8 ) - ( 2 + 3 ) ) ) "
function convert( input ) {
console.log( " --> " + input );
var result = input.match( /^(.*)\((.*?)\)(.*)$/ );
if (result == null) {
return input;
} else {
return convert( result[1] + "[" + result[2] + "]" + result[3] );
}
}
console.log( convert( " ( ( 1 + 2 ) + ( 3 + 4 ) ) " ) );
console.log( convert (" ( ( ( 3 - 2 ) + 2 ) / ( ( 1 + 8 ) - ( 2 + 3 ) ) ) ") );
[beixlei@silo 11162016]$ node convert.js
--> ( ( 1 + 2 ) + ( 3 + 4 ) )
--> ( ( 1 + 2 ) + [ 3 + 4 ] )
--> ( [ 1 + 2 ] + [ 3 + 4 ] )
--> [ [ 1 + 2 ] + [ 3 + 4 ] ]
[ [ 1 + 2 ] + [ 3 + 4 ] ]
--> ( ( ( 3 - 2 ) + 2 ) / ( ( 1 + 8 ) - ( 2 + 3 ) ) )
--> ( ( ( 3 - 2 ) + 2 ) / ( ( 1 + 8 ) - [ 2 + 3 ] ) )
--> ( ( ( 3 - 2 ) + 2 ) / ( [ 1 + 8 ] - [ 2 + 3 ] ) )
--> ( ( ( 3 - 2 ) + 2 ) / [ [ 1 + 8 ] - [ 2 + 3 ] ] )
--> ( ( [ 3 - 2 ] + 2 ) / [ [ 1 + 8 ] - [ 2 + 3 ] ] )
--> ( [ [ 3 - 2 ] + 2 ] / [ [ 1 + 8 ] - [ 2 + 3 ] ] )
--> [ [ [ 3 - 2 ] + 2 ] / [ [ 1 + 8 ] - [ 2 + 3 ] ] ]
[ [ [ 3 - 2 ] + 2 ] / [ [ 1 + 8 ] - [ 2 + 3 ] ] ]
[beixlei@silo 11162016]$
So we see how the pairs of parens are being identified, one by one.
Next one can do this:
[beixlei@silo 11162016]$ cat convert.js
// " ( ( ( 3 - 2 ) + 2 ) / ( ( 1 + 8 ) - ( 2 + 3 ) ) ) "
function convert( input ) {
console.log( " --> " + input );
var result = input.match( /^(.*)\((.*?)\)(.*)/ );
// ---- ----- ----
// ^ resu^lt[2] ^
// result[1] result[3]
if (result == null) {
return input;
} else {
var b = result[2];
var c = b.match( /^\s*(\d+)\s*(.)\s*(\d+)\s*$/ ); // number plus number
if (c == null) { // if it doesn't we need to try other patterns
c = b.match( /^\s*(\[.*?\])\s*(.)\s*(\[.*?\])\s*$/ ); // looking for [ ... ] + [ ... ]
if (c == null) { // if this does not match I can try to more patterns
c = b.match( /^\s*(\[.*?\])\s*(.)\s*(\d+)\s*$/ ); // I try now [ ... ] + number
if (c == null) { // if this doesn't work the last one I try is
c = b.match( /^\s*(\d+)\s*(.)\s*(\[.*?\])\s*$/ ); // number + [ ... ]
if (c == null) return " bleah "; // if this fails too I am sorry for the user (their expression was wrong!)
// some better error checking would be great (perhaps)
// if I get here though the fourth pattern matched
} // the third pattern matched
} // the second pattern matched
} // the first pattern matched
// if I get here it did match somehow so I can rewrite it
var d = result[1] + "[" + c[2] + " " + c[1] + " " + c[3] + "]" + result[3];
console.log( " **( " + d );
return convert( d );
// same pattern only this time we also rearrange the operators and the operands
}
}
console.log( convert( " ( ( 1 + 2 ) + ( 3 + 4 ) ) " ) );
console.log( convert (" ( ( ( 3 - 2 ) + 2 ) / ( ( 1 + 8 ) - ( 2 + 3 ) ) ) ") );
[beixlei@silo 11162016]$ node convert.js
--> ( ( 1 + 2 ) + ( 3 + 4 ) )
**( ( ( 1 + 2 ) + [+ 3 4] )
--> ( ( 1 + 2 ) + [+ 3 4] )
**( ( [+ 1 2] + [+ 3 4] )
--> ( [+ 1 2] + [+ 3 4] )
**( [+ [+ 1 2] [+ 3 4]]
--> [+ [+ 1 2] [+ 3 4]]
[+ [+ 1 2] [+ 3 4]]
--> ( ( ( 3 - 2 ) + 2 ) / ( ( 1 + 8 ) - ( 2 + 3 ) ) )
**( ( ( ( 3 - 2 ) + 2 ) / ( ( 1 + 8 ) - [+ 2 3] ) )
--> ( ( ( 3 - 2 ) + 2 ) / ( ( 1 + 8 ) - [+ 2 3] ) )
**( ( ( ( 3 - 2 ) + 2 ) / ( [+ 1 8] - [+ 2 3] ) )
--> ( ( ( 3 - 2 ) + 2 ) / ( [+ 1 8] - [+ 2 3] ) )
**( ( ( ( 3 - 2 ) + 2 ) / [- [+ 1 8] [+ 2 3]] )
--> ( ( ( 3 - 2 ) + 2 ) / [- [+ 1 8] [+ 2 3]] )
**( ( ( [- 3 2] + 2 ) / [- [+ 1 8] [+ 2 3]] )
--> ( ( [- 3 2] + 2 ) / [- [+ 1 8] [+ 2 3]] )
**( ( [+ [- 3 2] 2] / [- [+ 1 8] [+ 2 3]] )
--> ( [+ [- 3 2] 2] / [- [+ 1 8] [+ 2 3]] )
**( [/ [+ [- 3 2] 2] [- [+ 1 8] [+ 2 3]]]
--> [/ [+ [- 3 2] 2] [- [+ 1 8] [+ 2 3]]]
[/ [+ [- 3 2] 2] [- [+ 1 8] [+ 2 3]]]
[beixlei@silo 11162016]$
Sat Sep 23 -
Does the following look like a correct solution for Homework 05?
function parse( input ) {
var result = input.match( /^\s*\(\s*(\d+)\s*(.)\s*(\d+)\s*\)\s*$/ ); // ( 12 + 5 )
if (result == null) {
var result = input.match( /^\s*\(\s*(\d+)\s*(.)\s*(\(.+\))\s*\)\s*$/ ); // ( 3 - ( 19 + 2 ) )
if (result == null) {
var result = input.match( /^\s*\((.+\))\s*(.)\s*(\d+)\s*\)\s*$/ ); // ( ( 1 + 2 ) + 3 )
if (result == null) {
var result = input.match( /^\s*\(\s*(\(.+\))\s*(.)\s*(\(.+)\)\s*$/ ); // ( ... ) + ( ... )
if (result == null) {
return ""; // some sort of error handling
} else {
return "( " + result[2] + " " + parse(result[1]) + " " + parse(result[3]) + " )" ;
}
} else {
return "( " + result[2] + " " + parse(result[1]) + " " + result[3] + " )" ;
}
} else {
return "( " + result[2] + " " + result[1] + " " + parse(result[3]) + " )" ;
}
} else {
return "( " + result[2] + " " + result[1] + " " + result[3] + " )" ;
}
}
console.log( parse ( " ( 1 + ( 3 + 4 ) ) " ) );
console.log( parse ( " ( 12 + 19 ) " ) );
console.log( parse ( " ( ( 12 + 19 ) - 17 ) " ) );
console.log( parse ( " ( ( 12 + 19 ) * ( 17 - 34 ) ) " ) );
console.log( parse ( " ( ( ( 5 + 7 ) + 19 ) * ( 17 - (30 + 4) ) ) " ) );
In other words: can you find an input for which the function above fails to translate correctly?
Fri Sep 22 -
Today in lab please try to find yourself in the scores below:
You can see everything in this table, except whose line each line is.
Thu Sep 21 -
Here are the straight answers to the exam questions.
Each exercise can be tested directly like for example:
-bash-4.2$ cat q15.js
function fun(base, elem) {
console.log("Doing fun(", base, ",", elem, ") now. Result:", (elem - base));
return elem - base;
}
var a = [3, 2, 1];
console.log(a.reduce(fun, 5));
console.log( (fun(fun(fun(5, 3), 2), 1)) )
-bash-4.2$ node q15.js
Doing fun( 5 , 3 ) now. Result: -2
Doing fun( -2 , 2 ) now. Result: 4
Doing fun( 4 , 1 ) now. Result: -3
-3
Doing fun( 5 , 3 ) now. Result: -2
Doing fun( -2 , 2 ) now. Result: 4
Doing fun( 4 , 1 ) now. Result: -3
-3
-bash-4.2$
The above is an experiment associated with question #15 on the test.
Wed Sep 20 -
Here's the exam as administered in class today.
Exam continues in lab on Friday.
Tue Sep 19 -
Summary from office hours today to be posted here:
- ...
- ...
- ...
- ...
Mon Sep 18 -
Notes as we wrote them in class today in real time.
We're going to discuss this after exam next week:
http://physics.weber.edu/schroeder/html5/TutorialPacket.pdf
Sun Sep 17 -
Please see update(s) on What's Due?
Sat Sep 16 -
Renewed list of links for soon after the first exam:
- Core HTML5 Canvas Examples
- Will this work? (in your browser)
Fri Sep 15 -
Here's the part of Chapter 07 code that works like our Homework Assignment 04.
Thu Sep 14 -
Notes as we wrote them in class in real time yesterday.
The minute paper distributed in class yesterday.
Wed Sep 13 -
Here's the minute paper from Monday.
Tue Sep 12 -
The notes as we wrote them in class yesterday.
Mon Sep 11 -
Here's the minute paper with questions we discussed last Wed.
Sun Sep 10 -
Paula stopped by on Fri, during office hours, here's a quick summary:
- send late assignments to me through Canvas
- don't send e-mail with attachments to me directly
- you can attach whatever you want if you send through Canvas
E-mail remains a very sensitive, and delicate issue...
Then there was some meaningful content discussed as shown below.
In C211 we introduce foldl
(as well as foldr and several othe r higher-order functions).
-bash-4.2$ module load racket
-bash-4.2$ racket
Welcome to Racket v6.6.
> (foldl - 23 (list 4 2 3 1))
19
> (exit)
-bash-4.2$
The same is available in Javascript:
function minus(a, b) { return b - a; }
var a = [4, 2, 3, 1];
console.log( a );
var num = a.reduce(minus, 23);
console.log( num ); // 19
function fun(total, elem) { return total + " " + elem; }
function nuf(total, elem) { return elem + " " + total; }
var a = [4, 2, 3];
console.log( a );
var one = a.reduce(fun, " done ");
console.log( one ); // what do we get?
var two = a.reduce(nuf, " done ");
console.log( two ); // what do we get?
// how do I get 4 2 3 done ?
We also mentioned these links as examples: map, and other array methods...
Sat Sep 09 -
Please log into
silo .
At the prompt, type: node and then press Enter.
Type a few expressions and then exit, like so:
-bash-4.2$ node
> 1
1
> "abc"
'abc'
> 1 + 2
3
> "what" + "ever"
'whatever'
> process.exit()
-bash-4.2$
Here are a few other things you can do:
-bash-4.2$ pico -w shell.js
-bash-4.2$ ls -ld shell.js
-rw-r--r-- 1 dgerman faculty 280 Apr 12 13:52 shell.js
-bash-4.2$ cat shell.js
var stdin = process.openStdin();
process.stdout.write("htdp3e> ");
stdin.addListener("data", function(input) {
if (input.toString().trim() == "bye")
process.exit();
console.log("you entered: [" + input.toString().trim() + "]");
process.stdout.write("htdp3e> ");
});
-bash-4.2$ which node
/usr/bin/node
-bash-4.2$ node shell.js
htdp3e> 1
you entered: [1]
htdp3e> (define a 3)
you entered: [(define a 3)]
htdp3e> oh, man...
you entered: [oh, man...]
htdp3e> quit
you entered: [quit]
htdp3e> bye
-bash-4.2$
Explain what is going on. Enjoy your weekend.
Fri Sep 08 -
We plan to address some of this on Monday during lecture:
http://physics.weber.edu/schroeder/html5
Thu Sep 07 -
Notes as we wrote them in class yesterday.
Wed Sep 06 - Meaningful reference:
http://exploringjs.com/es6.html
Here's the answer to the last problem on today's minute paper:
-bash-4.2$ pwd
/u/dgerman/a202-workspace
-bash-4.2$ ls -ld twelve.js
-rw-r--r-- 1 dgerman faculty 438 Sep 6 11:50 twelve.js
-bash-4.2$ cat twelve.js
class Horse {
constructor(name) {
this.name = name;
}
talk() {
console.log( "I am a Horse, my name is " + this.name );
}
}
var a = new Horse("Leslie");
a.talk();
class Unicorn extends Horse {
constructor(name) {
super(name); // constructor chaining
}
talk() {
super.talk();
console.log("Je suis une licorne, je m'appelle: " + this.name);
}
}
var b = new Unicorn("Francois");
b.talk();
-bash-4.2$ node twelve.js
I am a Horse, my name is Leslie
I am a Horse, my name is Francois
Je suis une licorne, je m'appelle: Francois
-bash-4.2$
Tue Sep 05 - Homework 04 posted.
Mon Sep 04 - Lab 04 posted.
Sun Sep 03 - Homework 03 posted.
Sat Sep 02 - Lab 03 posted.
Fri Sep 01 - Syllabus link in Class Notes now active.
Thu Aug 31 -
Class Notes up to date on all links for August.
Wed Aug 30 -
Today in class we take a look at this (and not only).
Here are the notes as we wrote them in class today.
Tue Aug 29 -
Here's also a note from Santiago:
+----
| re: my office hours
+--------
| my office hours will start tomorrow
+------------
| monday/wednesday 11:00am to 12:30 pm
+----------------
| we will try having them in lindley hall 204
+------------
| but if it gets to crowded we can move them to
| the "abyss" located on the same floor.
+---------------------
| best,
| santi
+--------
Here's a follow up to what we did yesterday in class:
-bash-4.2$ pwd
/u/dgerman/a202-workspace/08282017
-bash-4.2$ ls -l
total 16
-rw-r--r-- 1 dgerman faculty 22 Aug 28 14:08 monday.html
drwxr-xr-x 26 dgerman faculty 4096 Aug 28 14:06 node_modules
-rw-r--r-- 1 dgerman faculty 192 Aug 28 14:06 server.js
-rw-r--r-- 1 dgerman faculty 801 Aug 28 14:18 warmup.html
-bash-4.2$ nohup node server.js > output.log &
[1] 164886
-bash-4.2$ nohup: ignoring input and redirecting stderr to stdout
-bash-4.2$ ls -l
total 20
-rw-r--r-- 1 dgerman faculty 22 Aug 28 14:08 monday.html
drwxr-xr-x 26 dgerman faculty 4096 Aug 28 14:06 node_modules
-rw-r--r-- 1 dgerman faculty 27 Aug 29 14:51 output.log
-rw-r--r-- 1 dgerman faculty 192 Aug 28 14:06 server.js
-rw-r--r-- 1 dgerman faculty 801 Aug 28 14:18 warmup.html
-bash-4.2$ cat output.log
Server running on 32775...
-bash-4.2$ ps -ef | grep dgerman | grep server
dgerman 164886 132271 0 14:51 pts/19 00:00:00 node server.js
dgerman 165197 132271 0 14:51 pts/19 00:00:00 grep --color=auto server
-bash-4.2$
More to come in class tomorrow.
Mon Aug 28 -
Here are today's notes as we wrote them in class in real-time.
Sun Aug 27 -
Here's a thought (and a warm-up exercise) before tomorrow's class:
- read/browser/peruse this sample document
- then serve Listing 1.6 from your own port on silo.
What is the meaning of it -- what do you think?
Fri-Sat Aug 25-26 -
Reading Assignments posted on What's Due? before each lecture.
Wed Aug 23 -
Canvas is now ready, please log into section
FA17-BL-CSCI-A202-12337
Here are the notes as we wrote them in class today.
Tue Aug 22 -
Class readings should be accessible now to all students enrolled.
Mon Aug 21 -
Notes as we wrote them in class today.
Fall semester starts, first lecture today @1:00pm in I107.
Updated by © Adrian German for A202/A598
|