Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 J 的初学者。我第一次尝试编写函数类似于 totient 函数。它需要一个数组,假设是某个数字的 i.num,num。然后计算与数组计数互质的元素数。
如果我像这样手动操作:
numbers =: i.7 #(1=( #numbers)+./numbers)#numbers
有用。结果是 6。
所以我想把它变成一个通用功能。
Tot =: monad :'(1=( #x)+./x)#x' Tot i.11
这失败了,我得到 x 的值错误。我不知道为什么。
monad 的变量应该是y,而不是x:
y
x
Tot =: monad :'(1=( #y)+./y)#y'
x是二元组的左参数。