Permalink
Browse files

Wrap comments at 80 chars.

  • Loading branch information...
1 parent 121425a commit 3f372b2463407505dad7359c1e84bf4f32de3142 @jcoglan committed Jun 29, 2012
Showing with 863 additions and 922 deletions.
  1. +5 −4 lib/heist.rb
  2. +3 −3 lib/heist/builtin/lib/character.scm
  3. +20 −26 lib/heist/builtin/lib/list.scm
  4. +1 −0 lib/heist/builtin/lib/logic.scm
  5. +12 −14 lib/heist/builtin/lib/numeric.scm
  6. +13 −14 lib/heist/builtin/lib/string.scm
  7. +3 −3 lib/heist/builtin/lib/util.scm
  8. +1 −0 lib/heist/builtin/lib/vector.scm
  9. +49 −56 lib/heist/builtin/primitives.rb
  10. +37 −46 lib/heist/builtin/syntax.scm
  11. +5 −5 lib/heist/parser/nodes.rb
  12. +20 −20 lib/heist/runtime/binding.rb
  13. +9 −10 lib/heist/runtime/callable/continuation.rb
  14. +54 −56 lib/heist/runtime/callable/function.rb
  15. +74 −78 lib/heist/runtime/callable/macro.rb
  16. +40 −42 lib/heist/runtime/callable/macro/expansion.rb
  17. +33 −31 lib/heist/runtime/callable/macro/matches.rb
  18. +32 −31 lib/heist/runtime/callable/macro/tree.rb
  19. +9 −10 lib/heist/runtime/callable/syntax.rb
  20. +13 −13 lib/heist/runtime/data/character.rb
  21. +40 −39 lib/heist/runtime/data/cons.rb
  22. +8 −8 lib/heist/runtime/data/expression.rb
  23. +13 −13 lib/heist/runtime/data/identifier.rb
  24. +14 −15 lib/heist/runtime/data/vector.rb
  25. +45 −45 lib/heist/runtime/frame.rb
  26. +20 −21 lib/heist/runtime/runtime.rb
  27. +68 −74 lib/heist/runtime/scope.rb
  28. +38 −41 lib/heist/runtime/stack.rb
  29. +28 −29 lib/heist/runtime/stackless.rb
  30. +23 −26 lib/heist/stdlib/birdhouse.scm
  31. +31 −32 lib/heist/trie.rb
  32. +2 −2 sicp/1/1-6.scm
  33. +2 −2 sicp/1/2-1.scm
  34. +9 −11 sicp/1/2-4.scm
  35. +2 −2 sicp/1/3-1.scm
  36. +4 −5 sicp/1/3-4.scm
  37. +2 −2 sicp/2/1-2.scm
  38. +4 −4 sicp/2/1-4.scm
  39. +3 −3 sicp/2/2-3.scm
  40. +11 −11 sicp/2/3-2.scm
  41. +34 −42 sicp/2/3-3.scm
  42. +5 −6 sicp/2/3-4.scm
  43. +24 −26 sicp/2/4-3.scm
  44. +0 −1 spec/heist_spec.rb
View
@@ -48,8 +48,9 @@ def parse(source)
parser.parse(source)
end
- # Returns the result of evaluating the given +Expression+ in the given +Scope+.
- # If the first argument is not an +Expression+ it will be returned unaltered.
+ # Returns the result of evaluating the given +Expression+ in the given
+ # +Scope+. If the first argument is not an +Expression+ it will be returned
+ # unaltered.
def evaluate(expression, scope)
return expression.value if Runtime::Value === expression
Runtime::Expression === expression ?
@@ -58,8 +59,8 @@ def evaluate(expression, scope)
end
# Returns the result of dividing the first argument by the second. If both
- # arguments are integers, returns a rational rather than performing
- # integer division as Ruby would normally do.
+ # arguments are integers, returns a rational rather than performing integer
+ # division as Ruby would normally do.
def divide(op1, op2)
[op1, op2].all? { |value| Integer === value } ?
Rational(op1, op2) :
@@ -1,7 +1,6 @@
; (char string)
-; Returns a character from a single-character string. Mostly
-; useful for succinct representation of characters in hand-
-; written Ruby code.
+; Returns a character from a single-character string. Mostly useful for succinct
+; representation of characters in hand-written Ruby code.
(define (char string)
(if (and (string? string) (= (string-length string) 1))
(string-ref string 0)
@@ -72,3 +71,4 @@
(define char-ci>? (char-compare-ci char>?))
(define char-ci<=? (char-compare-ci char<=?))
(define char-ci>=? (char-compare-ci char>=?))
+
@@ -24,9 +24,8 @@
(iter object 0))
; (append list ...)
-; Returns a new list formed by concatenating the arguments.
-; The final argument is not copied and the return value of
-; (append) shares structure with it.
+; Returns a new list formed by concatenating the arguments. The final argument
+; is not copied and the return value of (append) shares structure with it.
(define (append first . rest)
(cond ((null? rest) first)
((null? first) (apply append rest))
@@ -36,17 +35,16 @@
(apply append rest))))))
; (reverse list)
-; Returns a newly allocated list consisting of the
-; elements of list in reverse order.
+; Returns a newly allocated list consisting of the elements of list in reverse
+; order.
(define (reverse object)
(if (null? object)
object
(append (reverse (cdr object))
(list (car object)))))
; (list-tail list k)
-; Returns the sublist of list obtained by omitting the
-; first k elements.
+; Returns the sublist of list obtained by omitting the first k elements.
(define (list-tail list k)
(do ((pair list (cdr pair))
(i k (- i 1)))
@@ -60,13 +58,11 @@
; (memq obj list)
; (memv obj list)
; (member obj list)
-; These procedures return the first sublist of list whose
-; car is obj, where the sublists of list are the non-empty
-; lists returned by (list-tail list k) for k less than the
-; length of list. If obj does not occur in list, then #f
-; (not the empty list) is returned. Memq uses eq? to compare
-; obj with the elements of list, while memv uses eqv? and
-; member uses equal?.
+; These procedures return the first sublist of list whose car is obj, where the
+; sublists of list are the non-empty lists returned by (list-tail list k) for k
+; less than the length of list. If obj does not occur in list, then #f (not the
+; empty list) is returned. Memq uses eq? to compare obj with the elements of
+; list, while memv uses eqv? and member uses equal?.
(define (list-transform-search transform)
(lambda (predicate)
@@ -86,22 +82,20 @@
; (assq obj alist)
; (assv obj alist)
; (assoc obj alist)
-; Alist (for "association list") must be a list of pairs.
-; These procedures find the first pair in alist whose car
-; field is obj, and returns that pair. If no pair in alist
-; has obj as its car, then #f (not the empty list) is
-; returned. Assq uses eq? to compare obj with the car fields
-; of the pairs in alist, while assv uses eqv? and assoc
-; uses equal?.
+; Alist (for "association list") must be a list of pairs. These procedures find
+; the first pair in alist whose car field is obj, and returns that pair. If no
+; pair in alist has obj as its car, then #f (not the empty list) is returned.
+; Assq uses eq? to compare obj with the car fields of the pairs in alist, while
+; assv uses eqv? and assoc uses equal?.
(define assoc-list-search (list-transform-search car))
(define assq (assoc-list-search eq?))
(define assv (assoc-list-search eqv?))
(define assoc (assoc-list-search equal?))
; (map proc list1 list2 ...)
-; Returns a new list formed by applying proc to each member
-; (or set of members) of the given list(s).
+; Returns a new list formed by applying proc to each member (or set of members)
+; of the given list(s).
(define (map proc list1 . list2)
(if (null? list1)
list1
@@ -115,9 +109,8 @@
(apply map (cons proc rest)))))))
; (for-each proc list1 list2 ...)
-; Calls proc once for each member of list1, passing each
-; member (or set of members if more than one list given)
-; as arguments to proc.
+; Calls proc once for each member of list1, passing each member (or set of
+; members if more than one list given) as arguments to proc.
(define (for-each proc list1 . list2)
(do ((pair list1 (cdr pair))
(others list2 (map cdr others)))
@@ -147,3 +140,4 @@
((<= end 0) '())
(else (cons (car list)
(sublist (cdr list) 0 (- end 1))))))
+
@@ -15,3 +15,4 @@
; Returns true iff x is a boolean value
(define (boolean? x)
(or (eqv? x #t) (eqv? x #f)))
+
@@ -3,8 +3,8 @@
(define number? complex?)
; (exact? x)
-; Returns true iff the given number is exact i.e. an integer, a
-; rational, or a complex made of integers or rationals
+; Returns true iff the given number is exact i.e. an integer, a rational, or a
+; complex made of integers or rationals
(define (exact? x)
(or (rational? x)
(and (not (zero? (imag-part x)))
@@ -81,8 +81,8 @@
; (remainder n1 n2)))
; (quotient x y)
-; Returns the quotient of two numbers, i.e. performs n1/n2
-; and rounds toward zero.
+; Returns the quotient of two numbers, i.e. performs n1/n2 and rounds toward
+; zero.
(define (quotient x y)
(let ((result (/ x y)))
((if (positive? result)
@@ -91,8 +91,7 @@
result)))
; (remainder x y)
-; Returns the remainder after dividing the first operand
-; by the second
+; Returns the remainder after dividing the first operand by the second
(define (remainder x y)
(- (round x)
(* (round y)
@@ -128,10 +127,9 @@
(define ceiling ceil)
; (rationalize x tolerance)
-; Returns the simplest rational number that differs from x by
-; no more than tolerance. Here 'simplest' means the smallest
-; possible denominator is found first, and with that set the
-; smallest corresponding numerator is chosen.
+; Returns the simplest rational number that differs from x by no more than
+; tolerance. Here 'simplest' means the smallest possible denominator is found
+; first, and with that set the smallest corresponding numerator is chosen.
(define (rationalize x tolerance)
(cond ((rational? x)
x)
@@ -152,8 +150,7 @@
i)))))))))
; (make-polar magnitude angle)
-; Returns a new complex number with the given
-; magnitude and angle
+; Returns a new complex number with the given magnitude and angle
(define (make-polar magnitude angle)
(let ((re (* magnitude (cos angle)))
(im (* magnitude (sin angle))))
@@ -167,8 +164,8 @@
(sqrt (+ (* re re) (* im im)))))
; (angle z)
-; Returns the angle a complex number makes with the
-; real axis when plotted in the complex plane
+; Returns the angle a complex number makes with the real axis when plotted in
+; the complex plane
(define (angle z)
(let ((re (real-part z))
(im (imag-part z)))
@@ -182,3 +179,4 @@
acc
(iter (- y 1) (* y acc))))
(iter x 1))
+
@@ -39,44 +39,42 @@
(= (string-compare string1 string2 char<? char>?) 1))
; (string<=? string1 string2)
-; Returns true iff string1 is lexicographically less than or equal
-; to string2
+; Returns true iff string1 is lexicographically less than or equal to string2
(define (string<=? string1 string2)
(not (string>? string1 string2)))
; (string>=? string1 string2)
-; Returns true iff string1 is lexicographically greater than or equal
-; to string2
+; Returns true iff string1 is lexicographically greater than or equal to string2
(define (string>=? string1 string2)
(not (string<? string1 string2)))
; (string-ci<? string1 string2)
-; Returns true iff string1 is lexicographically less than string2,
-; ignoring differences in case
+; Returns true iff string1 is lexicographically less than string2, ignoring
+; differences in case
(define (string-ci<? string1 string2)
(= (string-compare string1 string2 char-ci<? char-ci>?) -1))
; (string-ci>? string1 string2)
-; Returns true iff string1 is lexicographically greater than string2,
-; ignoring differences in case
+; Returns true iff string1 is lexicographically greater than string2, ignoring
+; differences in case
(define (string-ci>? string1 string2)
(= (string-compare string1 string2 char-ci<? char-ci>?) 1))
; (string-ci<=? string1 string2)
-; Returns true iff string1 is lexicographically less than or equal
-; to string2, ignoring differences in case
+; Returns true iff string1 is lexicographically less than or equal to string2,
+; ignoring differences in case
(define (string-ci<=? string1 string2)
(not (string-ci>? string1 string2)))
; (string-ci>=? string1 string2)
-; Returns true iff string1 is lexicographically greater than or equal
-; to string2, ignoring differences in case
+; Returns true iff string1 is lexicographically greater than or equal to
+; string2, ignoring differences in case
(define (string-ci>=? string1 string2)
(not (string-ci<? string1 string2)))
; (substring string start end)
-; Returns a string composed of the characters from start (inclusive)
-; to end (exclusive) in string
+; Returns a string composed of the characters from start (inclusive) to end
+; (exclusive) in string
(define (substring string start end)
(list->string (sublist (string->list string) start end)))
@@ -115,3 +113,4 @@
; Returns a new string formed by concatenating the arguments
(define (string-append . strings)
(list->string (apply append (map string->list strings))))
+
@@ -1,6 +1,5 @@
-; Any built-in functions that we can implement directly
-; in Scheme should go here. If at all possible, write
-; builtins in Scheme rather than Ruby.
+; Any built-in functions that we can implement directly in Scheme should go
+; here. If at all possible, write builtins in Scheme rather than Ruby.
(define quit exit)
@@ -16,3 +15,4 @@
; (call/cc)
; Alias for (call-with-current-continuation)
(define call/cc call-with-current-continuation)
+
@@ -25,3 +25,4 @@
(do ((i (vector-length vector) (- i 1)))
((zero? i) vector)
(vector-set! vector (- i 1) fill)))
+
Oops, something went wrong.

0 comments on commit 3f372b2

Please sign in to comment.