Arc Forumnew | comments | leaders | submitlogin
Idomatic use of rem unstable?
4 points by Jekyll 6132 days ago | 2 comments
Is the short cut in allowing an element passed to rem be treated as a function worthwhile?

Consider: (def instab (a) (rem a (list a (uniq))))

Then this will always return a list containing one unique element, unless a is a function.

arc> (instab [ is _ _] ) nil

or even.

arc>(instab (fn(x y) (is x y))) Error: "#<procedure>: expects 2 arguments, given 1: #<procedure>"

The reason I'm making a fuss is; I worry that if I start writing utility functions idiomatically and then treat functions as first class entities my code is going to break in surprising ways.

The obvious work around is to split rem into 2 functions: rem which must take a function and a list, and reme which takes an element to remove and a list as it's parameters.



1 point by almkglor 6132 days ago | link

Incidentally, looking through arc.arc, it seems that almost all functions concerned with using lists as sets use the same 'testify function on the given test. 'testify is the culprit here; it transforms non-functions to [is _ x]. While it certainly makes it easier to munge an is-test to a function, it also prevents functions from being easily used as first-class objects.

-----

1 point by almkglor 6132 days ago | link

True; this is probably something that needs to be redesigned.

-----