J- 22 20个字符
'{','}' '{'&(,,~)~#
如何得出:
#'123' NB. string length
3
'Left' (,,~) 'Right' NB. dyad to concat L,R,R
LeftRightRight
'{' (,,~) '}' NB. using braces
{}}
'{'&(,,~) '}' NB. bind left argument, now it's a monad
{}}
'{'&(,,~) '{'&(,,~) '}' NB. twice
{{}}{}}
'{'&(,,~)^:2 '}' NB. ^: is monad functional power
{{}}{}}
'{'&(,,~)^:3 '}' NB. any integer
{{{}}{}}{{}}{}}
3 '{'&(,,~) '}' NB. convenient feature of dyadic &
{{{}}{}}{{}}{}}
'}' '{'&(,,~)~ 3 NB. swap argument order
{{{}}{}}{{}}{}}
'}' '{'&(,,~)~ #'123' NB. using string length
{{{}}{}}{{}}{}}
'{', '}' '{'&(,,~)~ #'123' NB. add final brace
{{{{}}{}}{{}}{}}
('{','}' '{'&(,,~)~#) '123' NB. works as a verb
{{{{}}{}}{{}}{}}
另外,也可以写成'{','{'&(,,~)&'}'@#相同的意思。
用法:
'{','}' '{'&(,,~)~# 'aaaa'
{{{{{}}{}}{{}}{}}{{{}}{}}{{}}{}}
f =: '{','}' '{'&(,,~)~# NB. can be assigned to a function
f 'VeryBig'
{{{{{{{{}}{}}{{}}{}}{{{}}{}}{{}}{}}{{{{}}{}}{{}}{}}{{{}}{}}{{}}{}}{{{{{}}{}}{{}}{}}{{{}}{}}{{}}{}}{{{{}}{}}{{}}{}}{{{}}{}}{{}}{}}{{{{{{}}{}}{{}}{}}{{{}}{}}{{}}{}}{{{{}}{}}{{}}{}}{{{}}{}}{{}}{}}{{{{{}}{}}{{}}{}}{{{}}{}}{{}}{}}{{{{}}{}}{{}}{}}{{{}}{}}{{}}{}}
f(n-1)吗?