Re: Help needed with List!
- To: mathgroup at smc.vnet.net
- Subject: [mg16934] Re: Help needed with List!
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Thu, 8 Apr 1999 02:32:38 -0400
- References: <7ec5kg$cu2@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
<alvaroo at my-dejanews.com> wrote in message news: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 > Alvaro: (i) IntegerDigits[123456 ] {1,2,3,4,5,6} and back FromDigits[%] 123456 But note IntegerDigits[-123456 ] {1,2,3,4,5,6} Sign[-123456] -1 We can also use Characters[ToString[-123456]] {"-","1","2","3","4","5","6"} and back StringJoin@@% "-123456" ToExpression[%] -123456 (ii) A = {1,2,3,4,3, 2} ;B = {1,3} ; If you will allow ordering and removal of duplicates Complement[A,B] {2,4} if not DeleteCases[A, Alternatives@@B] {2,4,2} Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565