This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 2.17 | |
(define (last-pair list) | |
(if (= (cdr list) () | |
(car list) ;; if statement parens fixed | |
(last-pair (cdr list)) ;; now it's called last-pair recursively | |
;; 2.18 | |
(define (reverse list) | |
(if (= (cdr list) ()) ;; if statement inserted | |
(= new-list (cons (car list) ()))) ;; extra paren added for if statement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; SICP Exercise 2.2 | |
(define (make-segment (start-segment end-segment)) | |
(define (start-segment (x y)) | |
(= (cons (x y)) start-segment) | |
(print-point start-segment)) | |
(define (end-segment (x y)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var person = document.getElementsByName (); | |
person["name"] = document.form.name.value; | |
person["age"] = document.form.age.value; | |
person["location"] = document.form.location.value; | |
function printPerson(data) { | |
document.getElementById("demo").innerHTML = person.age; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 2.2 | |
;; SICP Exercise 2.2 | |
;; takes x and y coordinates to create a point | |
(define (make-point x y) | |
(cons x y)) | |
(define (make-segment x1 y1 x2 y2) | |
;; needs implementation | |
(let |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (contains x alist) | |
(define (foldl f(x accum) alist) | |
(null? alist) | |
#false | |
(if (= (car alist) x) | |
#true | |
(foldl f(x accum) (cdr alist)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form> | |
Name: <Input type="textbox" name="name" /> <br /> | |
Check box if you're alive: <Input type="checkbox" name="alive" /> <br /> | |
<Input type="submit" name="submit" value="we win click!" onClick="pulse(form)" /> | |
</form> | |
<script type="text/javascript"> | |
function pulse(data){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function increment(x) { | |
return x + 1; | |
} | |
increment(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bubble_sort(an_array){ | |
var n = an_array.length; | |
var found_inversion = true; | |
while(found_inversion){ | |
found_inversion = false; | |
for (var i=1;i<n;i++){ | |
if(an_array[i-1] > an_array[i]) { | |
found_inversion = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function merge_sort(a_array) { | |
if (a_array.length < 2) { | |
return a_array; | |
} | |
var mid = parseInt(a_array.length / 2); | |
var left = a_array.slice(0, mid); | |
var right = a_array.slice(mid, a_array.length); | |
return merge(merge_sort(left), merge_sort(right)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function make_listnode(prev_list, x, next_list) { | |
var node = new Object(); | |
node["prev"] = prev_list; | |
node["value"] = x; | |
node["next"] = next_list; | |
return node; | |
} | |
var alist = make_listnode (blist, 1, null) |
OlderNewer