[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

mandriva,eclipse) extract digits from fixnums

lolveley

4/30/2009 11:54:00 AM

hi,

I want to do a basic thing but without succes:
if a=1232, let nb_nb=4 (the number of digits)
for i from 1 to nb_nb, I want the following results:
i=1 => res=1 (first digit of a) and NOT the number 01 (with a zero in
front of the 1)
i=2 => res=2 (same thing)
i=3 => res=3
i=4 => res=2

I tried a few things, like convert the number in array (it seems to keep
the "0" in the result)...

do you have a solution?

olivier.






___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail...


10 Answers

Robert Schaaf

4/30/2009 12:34:00 PM

0

You could try

a.to_s.split(//).collect {|s| s.to_i}

and extract nb_nb elements.

Bob Schaaf


On Apr 30, 2009, at 7:54 AM, lolveley wrote:

> hi,
>
> I want to do a basic thing but without succes:
> if a=3D1232, let nb_nb=3D4 (the number of digits)
> for i from 1 to nb_nb, I want the following results:
> i=3D1 =3D> res=3D1 (first digit of a) and NOT the number 01 (with a =
zero =20
> in front of the 1)
> i=3D2 =3D> res=3D2 (same thing)
> i=3D3 =3D> res=3D3
> i=3D4 =3D> res=3D2
>
> I tried a few things, like convert the number in array (it seems to =20=

> keep the "0" in the result)...
>
> do you have a solution?
>
> olivier.
>
>
> =09
>
> =09
> =09
> =
__________________________________________________________________________=
_=20
> Yahoo! Mail r=E9invente le mail ! D=E9couvrez le nouveau Yahoo! Mail =
et =20
> son interface r=E9volutionnaire.
> http://fr.mail...
>
>


7stud --

4/30/2009 12:58:00 PM

0

Olivier Lolveley wrote:
> hi,
>
> I want to do a basic thing but without succes:
> if a=1232, let nb_nb=4 (the number of digits)
> for i from 1 to nb_nb, I want the following results:
> i=1 => res=1 (first digit of a) and NOT the number 01 (with a zero in
> front of the 1)
> i=2 => res=2 (same thing)
> i=3 => res=3
> i=4 => res=2
>
> I tried a few things, like convert the number in array (it seems to keep
> the "0" in the result)...
>
> do you have a solution?
>

It's not clear to me what you want to do, but maybe this will help:

a=1232
str = a.to_s
p str

--output:--
"1232"

digits = []
str.length.times do |i|
digits << str[i, 1]
end

p digits

--output:--
["1", "2", "3", "2"]

> res=1 (first digit of a) and NOT the number 01

1 and 01 are the same *number*.
--
Posted via http://www.ruby-....

henry.p.goodman

6/6/2014 5:32:00 PM

0

On Friday, June 6, 2014 3:43:39 PM UTC+1, Giorgies E Kepipesiom wrote:
> On Friday, June 6, 2014 9:55:40 AM UTC-4, shel...@thevillages.net wrote:
>
> >
>
> > In the event of such a catastrophe that destroys all [human] life, then
>
> > why bother? Who is going to read it? Some super race aliens from outer
>
> > space who already have advanced much further that we have?
>
> > Uselessness! What is it that they say about a fool and his money?
>
>
>
> In general I would agree. But perhaps not. I didn't read the artical and I am only going by the summary posted here. It speaks of "badly damaged", not "catastrophe that destroys all [human] life". So perhaps some humans, including some Jewish humans, survive, and eventually they will have a sefer Torah to copy new ones from.
>
>
>
> If the "Israelis" mentioned here are funding the project, then I agree about a fool and his money. But perhaps other fools are funding the project, and these Israelis are saying that as long as you are wasting all this money anyway, we will give you a sefer Torah to include in your capsule. Hopefully it is a very old sefer Torah that is falling apart and can't really be used for public Torah reading anymore.
>
>
>
> GEK
>
> whishing everyone good Shabbos

Well they are seeking sponsors for each of the 304,805 letters in the Sefer so I assume they intend to send a new Sefer
Shabbat shalom
Henry Goodman

mm

6/6/2014 5:49:00 PM

0

On Fri, 6 Jun 2014 17:32:13 +0000 (UTC),
"henry.dot.goodman.at.virgin.net" <henry.p.goodman@gmail.com> wrote:

>
>Well they are seeking sponsors for each of the 304,805 letters in the Sefer=
> so I assume they intend to send a new Sefer
>Shabbat shalom
>Henry Goodman

Well, I don't see a point to that. They could use a posul sefer Torah
just as easily, with a note about where any flaws in it are located.
Plus they should include instructions for making parchment and ink.

They could use a printed Torah too, for that matter. I can never
remember the word for a photographed or photocopied copy.

There are sefer Torahs not everywhere but all over the world. It is
important to back up important writing, but if world gets so bad we
can't find a Torah scroll on earth, I doubt we'll be able to make it to
the moon either. Hmm. I guess someone will be going** and we just
have to tell him what to bring back. **Also doubtful.
--

Meir
It is better to eat an onion in Jerusalem than a cockerel in Egypt. 1055CE

Giorgies E Kepipesiom

6/6/2014 9:34:00 PM

0

On Friday, June 6, 2014 1:32:13 PM UTC-4, henry.dot.goodman.at.virgin.net wrote:
>
> Well they are seeking sponsors for each of the 304,805 letters in the Sefer so I assume they intend to send a new Sefer

So here is the answer to Mr Glickler's question. Writing a ST costs anywhere between US $35,000 and $60,000, depending on size and quality of the parchment, care taken by the sofer, etc. If "sponsors" are expected to contribute even as little as one dollar per letter, this project stands to net someone a lot of money. Mystery solved.

GEK

sheldonlg

6/7/2014 12:13:00 PM

0

On 6/6/2014 5:33 PM, Giorgies E Kepipesiom wrote:
> On Friday, June 6, 2014 1:32:13 PM UTC-4, henry.dot.goodman.at.virgin.net wrote:
>>
>> Well they are seeking sponsors for each of the 304,805 letters in the Sefer so I assume they intend to send a new Sefer
>
> So here is the answer to Mr Glickler's question. Writing a ST costs anywhere between US $35,000 and $60,000, depending on size and quality of the parchment, care taken by the sofer, etc. If "sponsors" are expected to contribute even as little as one dollar per letter, this project stands to net someone a lot of money. Mystery solved.
>
> GEK
>

....and the cost of the rocket ship to get it to the moon and land it
there safely? THAT was the money I was talking about. Yes, it wouldn't
be the only thing on that ship, but still.......

$60,000 would be a drop in the bucket. Add a few more zeros.

--
Shelly

Giorgies E Kepipesiom

6/8/2014 2:56:00 AM

0

On Saturday, June 7, 2014 8:12:42 AM UTC-4, shel...@thevillages.net wrote:
>
> ...and the cost of the rocket ship to get it to the moon and land it
> there safely? THAT was the money I was talking about. Yes, it wouldn't
> be the only thing on that ship, but still.......
> $60,000 would be a drop in the bucket. Add a few more zeros.

My understanding was that this launch is happening anyway, and is being underwritten by others, and the Torah was to be added as additional cargo. But if this launch is dedicated to - and paid for by - the Torah scroll people, then you may be right. However, I reserve judgement; these people find ingenious gimmics for making a dollar, and I am confident there is money to be made, though neither you nor I see how. Perhaps they already have a sponsor for the launch, having convinced him he is doing a big mitzva. The sponsorship of the scroll itself is now all profit. And who knows - perhaps these sponsors WILL get to Heaven because of it. As for me, I prefer to earn my ticket to Paradise by more conventional means.

GEK

mm

6/8/2014 5:39:00 PM

0

On Fri, 6 Jun 2014 21:33:46 +0000 (UTC), Giorgies E Kepipesiom
<kepipesiom@hotmail.com> wrote:

>On Friday, June 6, 2014 1:32:13 PM UTC-4, henry.dot.goodman.at.virgin.net wrote:
>>
>> Well they are seeking sponsors for each of the 304,805 letters in the Sefer so I assume they intend to send a new Sefer
>
>So here is the answer to Mr Glickler's question. Writing a ST costs anywhere between US $35,000 and $60,000, depending on size and quality of the parchment, care taken by the sofer, etc. If "sponsors" are expected to contribute even as little as one dollar per letter,

> this project stands to net someone a lot of money.

Where do you get that idea?

Do you think they will get a unique sponsor for each letter? They
won't.

Do you have any idea how much the private space company will charge to
carry it to the moon? On the first flight out? You have to add that
into the cost.**

Did you read "Each document will be housed in a space-ready capsule
designed to protect it from harsh radiation and temperature changes on
the moon for at least 10,000 years." How much do you think that will
cost? Plus it adds to the weight.

What will actually happen, if the plan succeeds, will be what happens
with Sifrei Torah meant for use on earth. That is, a few people will
pay thousands, others hundreds, and many will pay enough for several
letters, plus some letters wiill be paid for as gifts to or in honor of
someone else. and after all this, when there is not enough money, one of
the original big donors, or a new one, will pay the rest.

There will not be 304,805 donors, nowhere near that number, and no one
will make a lot of money, except the scribe, who will have to work long
and hard for it.


**One of the rocket companies, SpaceX, I think, plans to offer pleasure
trips to space for a million or two million dolllars per person, but
that's only one or two laps around the earth, at 90 minutes per lap.
It takes 4 or 5 days to get to the moon. A Sefer Torah weighs say 10
pounds instead of 150, 1/10th, but 4 days is 96 hours, 64 times the
time it takes to make one trip around the earth.

And 4 days to come back too, if that's the plan. Plus no
water-landing.

> Mystery solved.

>
>GEK

--

Meir
It is better to eat an onion in Jerusalem than a cockerel in Egypt. 1055CE

mm

6/8/2014 6:12:00 PM

0

On Sun, 8 Jun 2014 17:38:51 +0000 (UTC), mm <mm2005@bigfoot.com> wrote:

>
>**One of the rocket companies, SpaceX, I think, plans to offer pleasure
>trips to space for a million or two million dolllars per person, but
>that's only one or two laps around the earth, at 90 minutes per lap.
>It takes 4 or 5 days to get to the moon. A Sefer Torah weighs say 10
>pounds instead of 150, 1/10th,

1/15th, duh. But still the increase in time 64x and distance, is
much greater than the decrease in weight from a person, 1/15.

> but 4 days is 96 hours, 64 times the
>time it takes to make one trip around the earth.
>
>And 4 days to come back too, if that's the plan. Plus no
>water-landing.

--

Meir
It is better to eat an onion in Jerusalem than a cockerel in Egypt. 1055CE

Harry Weiss

6/9/2014 12:41:00 AM

0

Giorgies E Kepipesiom <kepipesiom@hotmail.com> wrote:
> On Friday, June 6, 2014 1:32:13 PM UTC-4, henry.dot.goodman.at.virgin.net wrote:
> >
> > Well they are seeking sponsors for each of the 304,805 letters in the Sefer so I assume they intend to send a new Sefer

> So here is the answer to Mr Glickler's question. Writing a ST costs anywhere between US $35,000 and $60,000, depending on size and quality of the parchment, care taken by the sofer, etc. If "sponsors" are expected to contribute even as little as one dollar per letter, this project stands to net someone a lot of money. Mystery solved.

> GEK

If this is anything like a shul which uses writing a Torah as a fund
raiser it is goood but not so good and most of the money comes from the
big sponsors who sponsor prime passages (Shma, Asseret Hadibrot x2, Shira
etc) as well as the last x letter that they write together with the Sofer,

The fact is for most shuld now where near 300k letters are sold.


--
Harry J. Weiss
hjweiss@panix.com