>>  <<  Ndx  Usr  Pri  Phr  Dic  Rel  Voc  !:  wd  Help  Primer

Cut ;.

The cut conjunction applies a verb to partitions of its argument. In discussing cut we will use the expression f =: u ;. n to give names to the various elements. The left argument of cut is the verb u that will be applied to partitions of the right argument of the derived verb f . The right argument of cut is the noun n that indicates the kind of partitions.

Let's consider cases where n is 1, _1, 2, or _2 and where the derived verb is used monadically.

If n is 2 or _2, the items of the right argument are partitioned into arguments that end with the last item in the argument. The item that is used to mark the partitions is called the fret. A negative n indicates that the fret is not included in the partition. Each partition is passed to the verb u and the partial results are assembled into the final result.

   cut2  =. < ;. 2

The definition of cut2 could be read as: box cut last.

   cut2 'how now brown cow '
+---------------------+
�how �now �brown �cow �
+---------------------+ 

In this example the items of the right argument are characters. The fret is the last character, which is a blank. The fret is used to break the entire argument into a series of arguments to which the verb < is applied. Visually:

< 'how '  (first partition)  gives  first partial result
< 'now '  (next partition)   gives  next partial result
< 'brown '
< 'cow '

The partial results are assembled into the final result.

   <;._2 'how now brown cow '
+-----------------+
�how�now�brown�cow�
+-----------------+

The cut2 boxed results include the fret and the <;._2 boxed results do not include the fret.

The following applies to the same partitions of the right argument, but applies the dyad # (tally) instead. This gives us the count of each partition.

   #;._2 'how now brown cow '
3 3 5 3

This applies in the same way to numeric data. In the following _1 is the fret.

   a =. 2 3 4 _1 5 3 2 _1 23 45 65 132 _1
   <;._2 a
+------------------------+
�2 3 4�5 3 2�23 45 65 132�
+------------------------+

   #;._2 a
3 3 4

   +/;._2 a
9 10 265

A 1 or _1 uses the first item as the fret. If positive, the fret is included in the result, if negative it is not included.

   <;._1 'madam i''m adam'
+-------------+
�ada� i'� ada��
+-------------+

Sometimes the partition information is separate from the data. Instead of frets in the data, the partition information can be provided in a left argument to the derived verb. The partition information is boolean data where a 1 indicates the start (with 1 or _1) or end (with 2 or _2) of the partitions.

   1 0 0 0 1 0 0 <;.1 'abcdefg'
+--------+
�abcd�efg�
+--------+

   d =.  'the test is the thing'
   'the' E. d
1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0

   ('the' E. d) <;.1 d
+----------------------+
�the test is �the thing�
+----------------------+

The example above uses a new primitive E. that you can look up in the J Dictionary if you want additional information at this time. However, without worrying about the details you should get the idea of what is happening.

Chopping up character lists into boxes is so useful that there is a standard utility called cutopen that handles many of the common cases. For example:

   cutopen 'testing testing 1 2 3'
+---------------------+
�testing�testing�1�2�3�
+---------------------+

>>  <<  Ndx  Usr  Pri  Phr  Dic  Rel  Voc  !:  wd  Help  Primer