sundaryourfriend


Joined 2 years ago
Homeworks submitted:
Homework comments:
2
2

About Me

No description provided.

Classes

Bash Scripting

Class status: Established
Role: Student
. 5% complete

How to Design Programs

Class status: Under Construction
Role: Student
. 100% complete

Structure and Interpretation of Computer Programs

Class status: Established
Role: Student
. 0% complete

Submitted Assignments

How to Design Programs: Lesson 1, HW 1

2.1 Scheme respects numbers - when they are inexact, it carefully tells us instead of dumping wrong output like most other languages. It understand rational numbers and complex numbers by default.

2.2 Almost anything can be in a variable or program name. There's a close correspondence between a Scheme 'program' and a mathematical 'function' - convert-gui and Ex 2.2.5 express this beautifully.

2.3 Interpreting wordy specifications to precise terms and making programs out of them is an important job of programmers.

2.4 Do not be sloppy about your parens.

2.5 Start your program with a contract and examples, write it, then test with the examples themselves.

(sqr 2)
(sin (/ pi 2))
(max 2 42)
2 ; this is (sqrt 4)
#i1.4142135623730951 ; this is (sqrt 2)
0+1i ; this is (sqrt -1)
(tan (/ pi 4))

(define (fahr->celsius fahrenheit)
  (* (- fahrenheit 32) 5/9))
(define (dollar->euro dollarval) 
  (* 0.738770686 dollarval))
(define (triangle side height)
  (* 1/2 side height))
(define (convert3 ones tens hundreds)
  (+ (* 100 hundreds) (* 10 tens) ones))
(define (f n)
  (+ (/ n 3) 2))
(define (f1 n)
  (+ (sqr n) 10))
(define (f2 n)
  (+ (* 1/2 (sqr n)) 20))
(define (f3 n)
  (- 2 (/ 1 n)))

(define (tax pay)
  (* pay 15/100))
(define (netpay-wrong hours)
  (* hours 12))
;I wrote this corrected version after reading it again and seeing the difference 'gross pay' and 'net pay'.
(define (netpay hours)
  (- (* hours 12) (tax (* hours 12))))
(define (sum-coins pennies dimes nickels quarters)
  (+ pennies (* 10 dimes) (* 20 nickels) (* 25 quarters)))
(define (total-profit num-attendees)
  (- (* 5 num-attendees) (+ 20 (* 0.5 num-attendees))))

;; area-of-circle number -> number
;; to compute the area of a circle given its radius
;; example: (area-of-circle 5) should be 78.539
(define (area-of-circle radius)
  (* pi (sqr radius)))
(area-of-circle 5) "should be" 78.539
;; area-of-ring number, number -> number 
;; to compute the area of a ring, given the 
;; radii of the hole (inner) and the full radius (outer)
;; example: (area-of-ring 3 5) should be 50.24
(define (area-of-ring inner outer) 
  (- (area-of-circle outer) (area-of-circle inner)))
(area-of-ring 3 5) "should be" 50.24

sundaryourfriend 1 year ago
Bash Scripting: Lesson 1, HW 1

I read only whatever the O'Reilly preview allowed - which is not very less since only a few pages seem to have been skipped. In particular, I could not read 2.4,5,10,11,12,17,18,22 parts. However, I can guess they are about "echo -n", ">>", head, tail, xargs, and ">!". Am I correct? :)

The 'type' command and the swapping of STDOUT and STDERR were new and very useful to me.

I'm planning to get an ebook version of this book soon.


sundaryourfriend 1 year ago