Index   <<   >>

Put it on the agenda
@. (if then else; case)

f`g @. t y  if t y is 0 , f y ; if it is 1 , g y
f0`...`fn @. t y  if t y is i , fi y

In a well-written quadratic equation package, the larger in magnitude of the two roots should be found first, and the smaller should be found by dividing the larger root into the constant term. A suitable verb for determining the larger in magnitude of two numbers is

   lgmg=.{.`{:@.(<&|/)

The test <&| is inserted (/) between the atoms of a 2-atom list, and yields 1 only if the first atom is less than the second atom in magnitude. If it yields 0 , head ({.) is applied; if it yields 1 , tail is ({:) is applied.

   lgmg 2 3
3
   lgmg 2 _3
_3
   lgmg 3 _2
3
   lgmg _3 _2
_3

This generalizes to a case statement if there are more than two situations. If the test yields i , the ith verb is chosen to apply to the argument. A polynomial rootfinder could be written (# gives the number of items in its argument):

   empty`scalar`linear`quadratic`other@.(4:>.#)