Get answers and suggestions for various questions from here

Functional 21-day introduction tutorial


There is always someone asking how to get started with functional functions. I have already said that as long as people who are literate, the functional formula has already begun. So of course you can get started in -21 days.

In the original APL, the average is usually written


And J, the average

avg =: +/ % #

A big improvement over J's original APL is that we no longer need to use it.

J uses the two functions [ and ]

x [ y = x
x ] y = y

When using J to use a pure function style to combine new functions, all that is used is a function. After all, [ ] is a true ordinary function, and ⍺⍵ is not.

What is this inspiration for us? How do we usually mean the average?

相加 除以 项数
+/   %   #

Except that J is calculated from right to left, we calculate from left to right, and there is no essential difference in writing. Corresponding to /, plus corresponding +. Alan J. Perlis has long said that Though the Chinese should adore APL, it's FORTRAN they put their money on. APL you can't respond to it is justifiable. J is already exactly the same. If you can't see it, then I can't help but ask, you can't read it.

We use the theory of words produced by people who are illiterate in the West. Of course, we will feel that there are various kinds of omissions, various kinds of reverse order, and various words. It is a natural statement that it is impossible to explain this with the theory of shit, which is naturally a problem with theory.

Take a look at the nine chapters of arithmetic


You must think that this is a noun because the mother is the denominator. That of course does not explain. Because our text is functional from more than two thousand years ago, you have to use the mother as a function, the role is to take the denominator, then all can explain.

In a style similar to ML, the approximation can be written like this

let 合(x:[分,分]) =
    实 = 并(互(乘)((母 x), (子 x)))

This leads to a problem, and your code can't be read aloud.

So, you have already got started with the functional formula, and you still have a more advanced form. Not the kind of .. (.) in Haskell.