fork(2) download
  1. #! /usr/bin/racket
  2.  
  3. (define (accumulate a b combiner null-value term next)
  4. (if (> a b)
  5. null-value
  6. (combiner (term a)
  7. (accumulate (next a) b null-value term next))))
  8.  
  9. (define (accumulate-iter a b combiner null-value term next)
  10. (define (iter a result)
  11. (if (> a b)
  12. result
  13. (iter (next a) (combiner result
  14. (term a)))))
  15. (iter a null-value))
  16.  
  17. (define (sum a b term next)
  18. (accumulate a b + 0 term next))
  19.  
  20. (define (product a b term next)
  21. (accumulate a b * 1 term next))
  22.  
  23. (define (sum-iter a b term next)
  24. (accumulate-iter a b + 0 term next))
  25.  
  26. (define (product-iter a b term next)
  27. (accumulate-iter a b * 1 term next))
  28.  
  29. (define (identity n) n)
  30.  
  31. (define (inc n) (+ n 1))
  32.  
  33.  
  34.  
  35. (sum 1 10 identity inc)
  36. (sum-iter 1 10 identity inc)
  37.  
  38. (product 1 10 identity inc)
  39. (product-iter 1 10 identity inc)
Runtime error #stdin #stdout #stderr 0.03s 8656KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: In procedure primitive-load:
ERROR: In procedure skip_block_comment: /home/vBpp9B/prog.scm:39:33: unterminated `#! ... !#' comment