Paste: list comprehension

Author: jon
Mode: factor
Date: Sun, 8 Aug 2010 14:42:24
Plain Text |
USING: arrays kernel math math.ranges sequences
sequences.product ;
IN: rosettacode.list-comprehension

: pythagorean? ( a b c -- ? )
    [ sq ] tri@ [ + ] [ = ] bi* ;

:: pythagoreans ( n -- list )
    [ n [1,b] [| x | x n [a,b] [| y  | y n [a,b] [| z |
       x y z pythagorean? [ { x y z } , ] when
    ] each ] each ] each
    ] { } make ;

New Annotation

Summary:
Author:
Mode:
Body: