나는 J를 배울 시도하고 내가 사용하고있는이 책은이 이 J 함수가 실행되지 않는 이유는 무엇입니까?
function =: 3:0 function statements그래서 난이 형식을 따라 접는 코드를 쓴 모나드 함수를 정의하는 적절한 방법 말한다. 내가 구문 대신 스택 오류의 3
h=:>:@[email protected]<[email protected]: :[: NB. gets all integers less than half of the input :[: forces error if used dyadicly
d=:(0&=|)~ h :[: NB. gets list where if one is set that index from h was a factor of the input y :[: forces error if used dyadicly
p=: 3:0 NB. tells us p is a monadic function
t =: d y
a =: i. 1
while. 1<#t
if. t~:0
a =: a, #t
end.
t=: _1 }. t NB. found first mistake wrong bracket but fixing that doesn't fix it
end.
a*1
)
NB. p gets a list of all integers that are factors of y
p 4
| syntax error
| p 4
p
3
NB. h and d run fine
h 4
1 2
h 7
1 2 3
d 7
1 0 0
d 4
1 1
J는 함수형 프로그래밍 언어가 아닙니다. 이것은 함수 수준의 프로그래밍 언어입니다. (차이점에 대한 논의는 함수 수준 프로그래밍에 관한 Wikipedia 기사를 참조하십시오.) –