3 ms·
"noun" in C: noun(c){A z;if(c<'0'||c>'9')R 0;z=ga(0,0,0);z->p=c-'0';R z;} "noun" in k: noun:{[c]$[(c<"0")|c>"9";0;c-"0"]} / $[boolean; true; false] The C
by icsa 12y ago
"noun" in C:
noun(c){A z;if(c<'0'||c>'9')R 0;z=ga(0,0,0);z->p=c-'0';R z;}
"noun" in k:
noun:{[c]$[(c<"0")|c>"9";0;c-"0"]} / $[boolean; true; false]
The C version is effectively the k version expanded with declarations, memory allocation and initialization. I would not be surprised if the interpreter was written in APL and transliterated to C.
- DonGateley 12y agoGiven his obvious facility with both languages I think you are right but that both those steps occurred simultaneously in real time. Arthur had learned how to think a problem in APL and was a wizard at transliteration.
- dragonwriter 12y agoI'm not saying the C isn't in functional style. I'm saying that it being in functional style has nothing to do with the absence of whitespace/newlines. Both the use of the functional style and the absence of whitespace no doubt reflect Whitney's language-independent programming preferences, but they are distinctly different things.