Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
| #lang racket | |
| (require 2htdp/image | |
| 2htdp/universe) | |
| ; Cell object. | |
| (define make-cell | |
| (lambda (x y) | |
| (list (list x y) #f))) |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
| @_1 = -> | |
| # sum of multiples of 3 or 5 (not both) under 1K | |
| answer = 0 | |
| for n in [1...1000] | |
| if n % 3 == 0 or n % 5 == 0 | |
| answer += n |
| // by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
| // MIT Style License | |
| *Classification of classes:* | |
| ============================================================================= | |
| | Dynamic | Static | |
| ----------------------------------------------------------------------------- | |
| | | | |
| | Coffee, Python, Ruby, | SmallTalk, built-in |
| # Project Euler #3 -> http://projecteuler.net/index.php?section=problems&id=3 | |
| # Q: What is the largest prime factor of the number 600851475143 ? | |
| # Generate a Sieve of Eratosthenes (an array loaded with prime numbers) | |
| primes = [] | |
| sieve = (set, pos) -> | |
| return false if pos >= set.length | |
| if set[pos] * set[pos] < set[set.length-1] | |
| primes = (x for x in set when x == set[pos] or x % set[pos] != 0) | |
| return sieve(primes,pos+1) |