Re: Help needed with List!

*To*: mathgroup at smc.vnet.net*Subject*: [mg16930] Re: Help needed with List!*From*: "David Keith" <dkeith at sarif.com>*Date*: Thu, 8 Apr 1999 02:32:37 -0400*Organization*: Hevanet Communications*References*: <7ec5kg$cu2@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

For the first question consider: In[1]:= ToExpression[Characters[ToString[123456]]] Out[1]= {1,2,3,4,5,6} ToString[123456] converts the number to a string form. Characters[] produces a list of the individual characters in the string. The characters "look" like numbers, but they're not. I presume you really want numbers, so ToExpression[] threads onto the list (it's listable) and converts each character to a number, since that is how the front end would interpret such input. To see this all clearly, do the operations one at a time instead of nesting them as I did here. For the second question consider: In[2]:= a={1,2,3,4} Out[2]= {1,2,3,4} In[3]:= b={1,2} Out[3]= {1,2} In[4]:= Select[a,!MemberQ[b,#]&] Out[4]= {3,4} This is a bit harder. It uses a pure function, which can be a little hard to get used to at first, but very worthwhile. Starting from the outside, Select[a,test], where I describe the test next, constructs a new list by selecting only those elements for which the applied test evaluates as True. The test here is a pure function: MemberQ[list,element] asks whether element occurs in list, so !MemberQ (the ! is "Not") is True if element is not in list. The element here is designated by #, which represents the argument of the pure function, and the & character is what tells Mathematica that this is a definition of a pure function. The list which MemberQ is testing elements against is b, so the Select function is creating a list of the members of a which do not appear in b. Regards, Dave alvaroo at my-dejanews.com wrote in message <7ec5kg$cu2 at smc.vnet.net>... >Sirs Probably these are FAQs but I am new in this newsgroup and I have not >been able to solve them. I use Mathematica 3.0: (i) I need to convert a long >integer number in List format. For example if I had the number 123456 I need >to convert it into {1,2,3,4,5,6}: Is it possible with an instruction? And, >(ii) I need to delete from a List A the common elements with other List B: >for example if A = {1,2,3,4} and B = {1,2} I need to delete by an instruction >the elements 1, 2 of List B from List A to obtain List C = {3,4}. I am >working with integers with 10.000 digits or more so you can appreciate how >helpful for me it would be to solve these questions. Thanks in advance. >alvaroo > >-----------== Posted via Deja News, The Discussion Network ==---------- >http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own >

**Need help about how to bring image to clipboard?**

**Transformation rules for Floor/Ceiling**

**Re: Help needed with List!**

**Re: Help needed with List!**