sequences: require non-negative-integer for iotas.
							parent
							
								
									5bcdeee745
								
							
						
					
					
						commit
						bbe5f32d5f
					
				| 
						 | 
				
			
			@ -313,6 +313,7 @@ M: bogus-hashcode hashcode* 2drop 0 >bignum ;
 | 
			
		|||
[ V{ 0 3 } ] [ "A" { "A" "B" "C" "A" "D" } indices ] unit-test
 | 
			
		||||
 | 
			
		||||
[ "asdf" iota ] must-fail
 | 
			
		||||
[ -1 iota ] must-fail
 | 
			
		||||
[ T{ iota { n 10 } } ] [ 10 iota ] unit-test
 | 
			
		||||
[ 0 ] [ 10 iota first ] unit-test
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -374,4 +375,3 @@ USE: make
 | 
			
		|||
        { 255 0 175 }
 | 
			
		||||
    } [ { 0 0 255 } distance ] infimum-by
 | 
			
		||||
] unit-test
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -104,7 +104,10 @@ INSTANCE: f immutable-sequence
 | 
			
		|||
! Integer sequences
 | 
			
		||||
TUPLE: iota { n integer read-only } ;
 | 
			
		||||
 | 
			
		||||
: iota ( n -- iota ) \ iota boa ; inline
 | 
			
		||||
ERROR: non-negative-integer-expected n ;
 | 
			
		||||
 | 
			
		||||
: iota ( n -- iota )
 | 
			
		||||
    dup 0 < [ non-negative-integer-expected ] when \ iota boa ; inline
 | 
			
		||||
 | 
			
		||||
M: iota length n>> ; inline
 | 
			
		||||
M: iota nth-unsafe drop ; inline
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue