Paste: Tracking down UNIX signal #8 (SIGFPE)

Author: Loryn Jenkins
Mode: factor
Date: Tue, 5 Mar 2013 06:53:03
Plain Text |
! In the below code, candidates-1a, -2ai fail with UNIX signal #8 (SIGFPE)
! In the below code, candidates-1b, -2aii, -2b all succeed.
! I'm running 64-bit VM on MacOSX
! What's likely to be going wrong?


: next ( x -- x+1 )
    1 + ;

:: iota-replacement ( max -- seq )
    0 [ next dup max < ] [ dup ] produce nip ;

:: candidates-1a ( target -- seq )
    target iota >array
    [ target swap mod 0 = ] filter ;
    
:: candidates-1b ( target -- seq )
    target primes-upto >array 
    [ target swap mod 0 = ] filter ;
    
:: candidates-2ai ( target -- seq )
    target iota >array
    [ target swap divisor? ] filter ;
    
:: candidates-2aii ( target -- seq )
    target iota-replacement >array
    [ target swap divisor? ] filter ;    
    
:: candidates-2b ( target -- seq )
    target primes-upto >array 
    [ target swap divisor? ] filter ;  

New Annotation

Summary:
Author:
Mode:
Body: