A quick alternative to David's solution if member doesn't work with lists is
to do something like this
member(set(L), x)
BUT... this quick test on my side:
procedure main()
L := [1, "2", 3]
write ( if member(L, "4") then "YES!" else "NO!")
write ( if member(L, 1) then "YES!" else "NO!")
write ( if member(L, 2) then "YES!" else "NO!")
write ( if member(L, "3") then "YES!" else "NO!")
end
gave the following output:
NO!
YES!
YES!
YES!
This shows that:
1. member() works with list
2. integers (and probably reals) and their equivalent string literals are
a match and they pass the member() test.
If it doesn't work on someone's side, please report your platform in
addition to Unicon version number.
-Jafar
On Tue, Sep 27, 2011 at 2:00 PM, David Gamey <[email protected]> wrote:
> I think it's a bug.
>
> From ub3 "member(x, ...) returns x if its second and subsequent arguments
> are all members of set,
> cset, list or table x but fails otherwise. If x is a cset, all of the
> characters in subsequent
> string arguments must be present in x in order to succeed."
>
> Of course he could always do something like this ....
>
> procedure member(X[])
> static builtin
> initial builtin := proc("member",0)
> if *X > 1 then
> if type(X[1]) ~== "list" then return builtin!X
> else {
> every x := X[2 to *X] do
> if x === !X[1] then next else fail
> return X[1]
> }
> end
>
> in the short term.
>
> David
>
> ------------------------------
> *From:* Steve Wampler <[email protected]>
> *To:* [email protected]
> *Sent:* Tuesday, September 27, 2011 9:16:33 AM
> *Subject:* Re: [Unicon-group] [unicon-group] member
>
> On Tue, Sep 27, 2011 at 01:59:01PM +0100, John Sampson wrote:
> > For beginners it might be useful in a future version if an attempt to use
> > 'member' with a list as first argument gave an error message. It is not
> > obvious from the term that it applies to sets and tables but not lists.
> > If one uses it with a list it just mysteriously fails.
>
> John has a good point and raises an interesting question:
>
> Why shouldn't member(["a","b","c"], "c") work? Yes, it would
> be slower than testing membership in a set or table, but...
>
>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Unicon-group mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/unicon-group
>
>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Unicon-group mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/unicon-group
>
>
--
"Let there be no compulsion in religion: Truth stands out clear from error"
[The Holy Qur'an 2:256]
"Injustice anywhere is a threat to justice everywhere" Dr. King
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group