! Copyright (C) 2013 Your name.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel sequences math math.functions arrays math.combinatorics ;
IN: pythagorean-triples
: a-b-list ( n -- seq )
iota rest 2 all-combinations ;
: a-b-c ( seq1 -- seq2 )
[ first ]
[ second ]
[ [ first sq ] [ second sq ] bi + sqrt ]
tri
3array ;
: a-b-c-list ( n -- seq )
a-b-list [ a-b-c ] map ;
: float.0? ( n -- ? )
dup floor 0 ~ ;
: (pythagoreans) ( n -- seq )
a-b-c-list [ third float.0? ] filter ;
: pythagoreans ( n -- seq )
(pythagoreans) [ [ first ] [ second ] [ third >integer ] tri 3array ] map ;
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk