Arc Forumnew | comments | leaders | submitlogin
1 point by sjs 6132 days ago | link | parent

Makes sense to me. It's a trivial change in ac.scm for < and >. What about (<= 1 2 3) and (>= 3 2 1)? The easiest way to do the same for those two is to return the last value compared, which would be 3 and 1 respectively. That doesn't exactly jibe with < and > though so I hesitate to make such a change. Thoughts?

It seems logical that <= and >= should also return some meaningful value if < and > do. If we come up with something good I'll push it to the anarki repo (git wiki). Although, we could always just ignore <= and >= for now.



1 point by greatness 6129 days ago | link

Why not follow the same idea as < and >:

  (def <=? args 
    (if (apply <= args) (car args)))

-----

1 point by sjs 6127 days ago | link

I should have been clearer. I agree the semantics should be the same, I just didn't see an immediately clean way to add that to the current, recursive <= and >= functions. A thin wrapper would work just fine.

-----

1 point by greatness 6123 days ago | link

Yeah, either that or use a lambda function inside their definitions:

  (def >= args
    (let f (afn (ar) (or no.ar
                       (no:cdr ar)
                       (and (no:< car.ar cadr.ar)
                       (self:cdr ar))))
      (if (f args) car.args)))

-----