1 ! Copyright (C) 2012 John Benediktsson
2 ! See https://factorcode.org/license.txt for BSD license
4 USING: combinators.short-circuit grouping kernel math
5 math.primes sequences ;
9 : twin-primes-upto ( n -- seq )
10 primes-upto 2 clump [ first2 - abs 2 = ] filter ;
12 : twin-primes? ( x y -- ? )
13 { [ - abs 2 = ] [ nip prime? ] [ drop prime? ] } 2&& ;