Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the motivation for J to introduce fork

For the evolution from APL to J, What's the motivation to introduce fork? I guess it is nice to have (+/ % #) for calculating the average, but it also makes it harder to read longer verb train. Facing this tradeoff, is there any compelling reason for the APL inventor to choose this style in J?

like image 551
ahala Avatar asked Jan 23 '14 14:01

ahala


2 Answers

Thanks for Bob's answer. To make it stronger, now I learned that the necessity of fork as below.

  • The motivation of introducing fork is to implement tacit programming as a realization of Combinatory logic. you need sort of basis combinators for this ( like the s-k basis on wiki) , and hook/fork form a complete basis. Fork or its equivalent is really unavoidable for this purpose.

  • the concept of fork is natural if thinking of f + g, f * g. In math they usually mean f(x) + g(x) and f(x) * g(x).

  • This topic was explained nicely in Roger Hui's essay on verb trains.

like image 128
ahala Avatar answered Oct 25 '22 23:10

ahala


I suppose that fork has the motivation of combining existing functions to form a new function. Composition of functions in J is represented by @: or @ to create a new function from functions f and g, f@:g. Which means take the results of g and process them with f

Fork does the same but allows us to process the results of two different functions (right and left tine) using a third function (central tine). So (f h g) applies the results of f and g to the central tine h. The fork construct is interesting because it is a way of generating a new function by grouping functions without needing an additional symbol. As you pointed out it is extendable so that (a b c d e) is read as (a b (c d e)) where the result of the fork c d e is used as the right tine.

like image 3
bob Avatar answered Oct 26 '22 00:10

bob