JPhrases/VerbTrains

From J Wiki
Jump to navigation Jump to search

2G. Verb Trains

The following phrases illustrate how trains may be substituted for other constructs, often giving expressions that are more readable, particularly to readers more familiar with expressions from mathematics:

m0=: >: @ +: @ i. First odd integers
m1=: 1: + 2: * i. Same as m0
m2=: +/ @ (1: + 2: * i.) Sum of odd integers
m3=: [: +/ 1: + 2: * i. Same as m2 using cap
m4=: m2 -: *: Sum of odds is square (Tautology)
m5=: < i. 1: The first element where x<y ;  also works for = ~: < <: >: > E.
m6=: < i. 0: The first element where not x<y
m7=: < i: 1: The last element where x<y
m8=: < i: 0: The last element where not x<y
m9=: [: +/ < The number of elements where x<y