This file contains hidden or 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
//Selecting Item Colours | |
$(".dress-container .select-colour a").click(function(){ | |
//find the colour range | |
var colourRange = $(this).parent().next(".colours"); | |
//find the links in the colour range | |
var colourRangeLink = $(colourRange).find("a"); | |
//showing colour range | |
$(colourRange).show(); | |
This file contains hidden or 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
(lambda (n) (+ n 1)) |
This file contains hidden or 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
; letfn is a Clojure macro that allows for mutually recursive functions. | |
; In some lisps, letfn (or letrec) will expand to a lambda expression. | |
(letfn [(fact-helper [total n] | |
(if (<= n 1) | |
total | |
(fact-helper (* n total) (- n 1))))] | |
(defn fact [n] | |
(fact-helper 1 n))) | |
(fact 5) ; 120 |
This file contains hidden or 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
; This function returns a closure. That is, the returned anonymous function | |
; saves a reference to the free variable "n". | |
(defn make-adder [n] | |
"Returns a function that sums a given value (m) with n." | |
(fn [m] | |
(+ n m))) | |
(def add-10 (make-adder 10)) | |
; When we invoke the function, rather than creating a new environment, it will |
This file contains hidden or 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
;;; Calculates all elements of Pascal's Triangle up to a particular width/row. | |
(define (pascal width) | |
(reverse (pascal-helper '((1)) width))) | |
(define (pascal-helper rows width) | |
(if (= (length rows) width) | |
rows | |
(pascal-helper (cons (next-row (car rows)) | |
rows) |
NewerOlder