Skip to content
isawdrones edited this page Apr 2, 2011 · 1 revision

*x returns the first element of a list. Equivalent to: ,/1# or {(1#x)@0}

The first element is picked from the highest dimension of the list and has a shape of: 1_^: and a count of {:[1<#^x;*1_^x;1]}.

If the list is empty a fill item of the type is returned.

  *2 3 4 5
2

  *"kona"
"k"

  es:{x#!*/x}                 / enumerate by shape
  sf:1_^:                     / shape of first
  cf:{:[1<#^x;*sf x;1]}       / count of first

  a:es 4 5
(0 1 2 3 4
 5 6 7 8 9
 10 11 12 13 14
 15 16 17 18 19)

  *a
0 1 2 3 4

  b:es 3 2 3
((0 1 2
  3 4 5)
 (6 7 8
  9 10 11)
 (12 13 14
  15 16 17))

  *b
(0 1 2
 3 4 5)

  (sf b) ~ ^*b
1
  (cf b) ~ #*b
1
  *!0
0
  *0#0.0
0.0
  *""
" "
Clone this wiki locally