views:

87

answers:

2

I've seen in a lot of AI related stuff the symbol <-. For example,

delta <- 0
x <- x + 1

etc.

I always assume its meaning is the same as =(assigment), but probably they have a meaning that's a bit different from assigment, I assume?

Thanks

+2  A: 

Nope, that's pretty much it, you're correct in your assumption that it's a basic assignment.

In particular it means "assign value 0 to delta" and "assign value x+1 to x" in your samples.

Mark E
Then why don't they use = like the rest of the world?
devoured elysium
@devoured elysium: Some languages use `:=` for assignment, others allow both `<-` or `=`, e.g.: https://stat.ethz.ch/pipermail/r-help/2009-February/189314.html
Adam Bernier
@devoured, because '=' to the rest of the world (other than a few deranged computer geeks) means equality, not assignment :-)
paxdiablo
@devoured: Not all the rest of the world uses `=`. To a mathematician, the statement `x = x + 1` looks very wrong. Languages derived from Algol use `:=` for assignment.
Greg Hewgill
+8  A: 

It's assignment. It removes ambiguity that the "=" symbol adds, because that symbol is often overloaded to test equality.

It makes it very clear that the thing on the left is being assigned the thing on the right, rather than being matched, unified, or otherwise made equal to it.

Eli