1. adding numbers

This is a multi-part message in MIME format.

------=_NextPart_000_005A_01C20CD9.60765700
	charset="iso-8859-1"

In My latest program I Need tobe abble to add two numbers which apper in =
a sequence together E.g "{1,6) =3D {16}" This probaly is very trivial =
but it really needs to be done

------=_NextPart_000_005A_01C20CD9.60765700
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3D"Times New Roman">In My latest program I Need tobe =
abble to add=20
two numbers which apper in a sequence together E.g "{1,6) =3D {16}" This =
probaly=20
is very trivial but it really needs to be =

------=_NextPart_000_005A_01C20CD9.60765700--

new topic     » topic index » view message » categorize

2. Re: adding numbers

In My latest program I Need tobe abble to add two numbers which apper in a
sequence together E.g "{1,6) = {16}" This probaly is very trivial but it
really needs to be done


Well, first off, you should try to capture them differently so they're not
in a sequence. If that's just totally impossible, well... uh... We'll cross
that bridge if we have to.

new topic     » goto parent     » topic index » view message » categorize

3. Re: adding numbers

sequence n
object v

n = {1,6,2,3,4,0}
n+=48 -- the ascii value of '0', assumes n[x] is between 0 and 9.
v = value(n)
if v[1]=GET_SUCCESS then v=v[2] end if

HTH,
Michael J. Sabal

>>> orpheus_mullen at btopenworld.com 06/05/02 04:38PM >>>

In My latest program I Need tobe abble to add two numbers which apper
in a sequence together E.g "{1,6) = {16}" This probaly is very trivial
but it really needs to be done

new topic     » goto parent     » topic index » view message » categorize

4. Re: adding numbers

sequence a,b

a = {1,6}
b =  {a[1]*10+a[2]}

C. K. Lester wrote:

>
>
>
>In My latest program I Need tobe abble to add two numbers which apper in a
>sequence together E.g "{1,6) = {16}" This probaly is very trivial but it
>really needs to be done
>
>
>Well, first off, you should try to capture them differently so they're not
>in a sequence. If that's just totally impossible, well... uh... We'll cross
>that bridge if we have to.
>
>
>
>

new topic     » goto parent     » topic index » view message » categorize

5. Re: adding numbers

Hi 

Here's the solution:

sequence a
a=3D(1,6)

a=3D10*a[1]+a[2]

EUrs  Antoine

new topic     » goto parent     » topic index » view message » categorize

6. Re: adding numbers

OOPS

sequence a
a=3D{1,6}

a=3D {10*a[1]+a[2]}

This should do ie the correct way I guess
Didn't test.
maybe result wil be {{16}}

antoine

new topic     » goto parent     » topic index » view message » categorize

7. Re: adding numbers

"Derek Parnell" wrote:

> That all depends on what the specification is. Some examples might help
> here...
>
> So far we know that
>   {1,6} ==> {16}
> must be true
>
> but we are assuming
>   {23,17} ==> {247}
>
> or this
>   {23, 17} = {2317}
>
> That is why clear specifications are so important for programming.

Here's a quick kluge that deals with some of the apparent problems, but
introduces a whole heap of others ;) ...:

-- Warning! No error or bounds checking in this code!
sequence in, outseq
integer out
in = {1, 23, 456}
outseq = ""
out    = 0  -- want this to be 123456

for i = 1 to length(in) do
    outseq &= sprintf("%d", in[i])-'0'
end for
for i = 1 to length(outseq) do
    out = out * 10 + outseq[i]
end for

? out

Carl

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu