4 ms·
but he still have variables...
by msh 13y ago
but he still have variables...
- tehwalrus 13y agothey could all be declared const and the program would still run.
- evincarofautumn 13y agoHere’s a (non–tail-recursive) solution in Factor that doesn’t. : collatz ( n -- length ) { { [ dup 1 = ] [ drop 0 ] } { [ dup even? ] [ 2 / collatz 1 + ] } [ 3 * 1 + collatz 1 + ] } cond ; Usage: 27 collatz
- jfarmer 13y agoThere is no place where he's assigning a value to an already-defined variable. Nothing is "varying." Perhaps the restriction can be put this way: you're only allowed to define variables by naming them as an argument to some function and then calling that function with some value.
- derefr 13y agoStill, this isn't what I expected when I clicked the link; I was expecting something about point-free or combinatoric programming :)
- pjmlp 13y agohe is using them as values
- msh 13y agoyou might have a point, but it was not what I was expecting when I clicked the link.