Help Contents / Data Structure Primitives / Selectors / firsts

firsts list

outputs a list containing the FIRST of each member of the input list.  It is an error if any member of the input list is empty. (The input itself may be empty, in which case the output is also empty.)  This could be written as 

	to firsts :list 
		output map "first :list 
	end 

but is provided as a primitive in order to speed up the iteration tools MAP, MAP_SE, and FOREACH. 

New in 4.689 is that Array arguments are now allowed. 

Examples: 

	show firsts [[H a l l o] [W o r l d]]		;[H W] 

	to transpose :matrix 
		if emptyp first :matrix [op []] 
		op fput firsts :matrix transpose bfs :matrix 
	end 

	show firsts {{1 2 3}[a b c]}		;{1 a} 


previous: BitItem	next: butFirsts
