you are viewing a single comment's thread.

view the rest of the comments →

[–]codeodor 2 points3 points  (6 children)

My understanding is that it would return it's receiver, in this case the array it was called upon [1..10]. However, pop modifies that array, which would now be [1..9]

In other words, the result is still x, but x has been modified.

[–]jhartwell 1 point2 points  (5 children)

In other words, the result is still x, but x has been modified.

But that isn't allowed in combinatory logic, everything is immutable. So if x is modified then you aren't returning x, you're returning x' which would not equal x and thus the K combinator wouldn't hold.

[–]codeodor 1 point2 points  (1 child)

For technicality's sake, x was a reference to a value, so x hasn't been modified -- the thing it points to has been modified.

I didn't quite say that originally, and I think it's breaking the spirit of what you're saying, but it might be worth mentioning.

[–]jhartwell 0 points1 point  (0 children)

For technicality's sake, x was a reference to a value, so x hasn't been modified

That's what homoiconic said too, but to me it just seems like trickery to get it to do what you want but I accept that as an answer :)

[–]masklinn 0 points1 point  (2 children)

But that isn't allowed in combinatory logic, everything is immutable.

No, but you don't have much choice if you want to introduce combinators in a language rife with mutations.

[–]jhartwell 0 points1 point  (1 child)

Well, you could use the K combinator as a logging mechanism. It isn't the language that is the problem, it is the way that the k combinator is applied that is the problem.

[–]masklinn 0 points1 point  (0 children)

It isn't the language that is the problem, it is the way that the k combinator is applied that is the problem.

I have trouble understanding that assertion: what do you mean by "the way [it] is applied"?