Arc Forumnew | comments | leaders | submitlogin
1 point by sacado 6068 days ago | link | parent

(= 1 1) is written (is 1 1) in Arc. The equal sign is used for affectation. You get an error as 1 cannot be set. So, for your first question,

  if x == 0 return 1 else return 2
is translated as

  (if (is x 0) 1 2)
As for DrScheme, I don't know, sorry :)


4 points by dreish 6067 days ago | link

Although this does bring up an unfortunate characteristic of 'is':

  arc> (is 0 0.0)
  nil
It might be nice to have an == that does a numeric comparison, if floats and ints are always going to be considered unequal by 'is'.

-----

2 points by tokipin 6067 days ago | link

in the meantime i have devised a clever scheme i call "natural coercion":

  arc> (with (x 0 y 0.0)
          (is (+ x 0.0) (+ y 0.0)))
  t
it can be toolified as:

  (def eq args
      (apply is (map [+ _ 0.0] args)))

-----

2 points by eds 6067 days ago | link

I would have expected 'iso to work for that, but it also returns nil.

  arc> (iso 0 0.0)
  nil

-----

1 point by sacado 6067 days ago | link

You're right. This is really strange as 0.0 is considered as an 'int.

-----

3 points by rincewind 6067 days ago | link

This may be related to http://arclanguage.org/item?id=5720

-----

1 point by sacado 6067 days ago | link

Hmmm... very possible...

-----