Those who bring sunshine to the lives of others cannot keep it from themselves. J. M. Barrie
Idea Transcript
Sequece of Prime Numbers You can edit and run the following code. Enjoy Egison programming! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
;;; ;;; ;;; Pattern-matching against sequence of natural numbers ;;; ;;; ;; Extract all twin primes from the infinite list of prime numbers with pattern-matching! (define $twin-primes (match-all primes (list integer) [ [p (+ p 2)]])) ;; Enumerate first 10 twin primes (take 10 twin-primes) ;; Extract all prime-triplets from the infinite list of prime numbers with pattern-matching! (define $prime-triplets (match-all primes (list integer) [ [p m (+ p 6)]])) ;; Enumerate first 10 twin primes (take 10 prime-triplets)
Run
What to do next... Next Demonstration (./tree.html) Back to Home (/)
comments powered by Disqus (http://disqus.com)
This website in other langauge: English (/), (/ja/)