[M3devel] add/subtract in Quake

Jay K jay.krell at cornell.edu
Fri Jul 2 10:20:26 CEST 2010


If someone can specify and/or implement, yes.
In the meantime I'll proceed without.


It appears many newlines were lost from my email rendering it unreadable. Arg.


Then we maybe need for loops.
And comparison and bitwise operation and shifting -- consider the case of 
combinatorial test generation...you nested for loop various integers from 0 to 1
and then shift them each a different amount, oring them together to get a test number...

Or you loop from 0 to 2^n and you check for a bit set to decide which variation
of that variable to generate.


Or maybe we need a different scripting language.
Python is very good.
A friend is telling me about Lua.
  Need to check about portability to OpenBSD/mips64..never quite got Python working there, but close..
:)


Or maybe we should use makefile.m3 that gets compiled on-demand or something.
  Really. Maybe. makefile.m3 around m3-sys would have to limit itself to working with old compiler/m3core/libm3.


You know.."compiled languages" ought to compete better with "scripting languages".. the distinction belies
any technical classification, to me. What is a "scripting language" vs. others?
They are often interprted. But not always. Quake is acually compiled in a way.
Often dynamically typed. But not always.
Often lack tools for turning them into "executables". But not always.
Often are slow. But not always.
Usually are "safe". Always?
  But so sometimes are others: Modula-3, C#, Java, etc.


 - Jay

----------------------------------------
> Date: Fri, 2 Jul 2010 09:34:19 +0200
> From: wagner at elegosoft.com
> To: m3devel at elegosoft.com
> Subject: Re: [M3devel] add/subtract in Quake
>
> Shouldn't we rather define some standard quake functions and implement
> them in M3, like add, substract, multiply, div, mod?
> Probably working on TEXT of course... or even introduce a new
> quake type for integers?
>
> I haven't really thought about that, but I've missed integer arithmetics
> several times in the past, too.
>
> Olaf
>
> Quoting Jay K :
>
> > Folks might find this amusing or useful. I actually think I'm
> > going to use it, just for the numbers 0-64.It implements addition
> > and subtraction for a fixed range, here 0-9999Global variables are
> > only used for initialization.Thereafter, just global constants (no
> > enforcement of that, but I think it could be done by having
> > initialization return them).
> > Approach is that adding 1 to a single digit can be done with a small
> > map.Adding 1 to multiple digits can be done using multiple
> > variables and checking for "wraparound" to 0 (the table maps 9 to
> > 0).You count up to 9999, filling in an Add1 and Sub1 hash table as
> > you go up. I don't think quake has an appropriate looping
> > mechanism, so counting up to 9999 is done recursively.Then Add and
> > Sub are implemented recursively like Add1{Add(a, Sub1(b)}.
> >
> > local Add1 = { }local Sub1 = { }
> >
> > local counter0 = 0local counter1 = 0local counter2 = 0local counter3 = 0
> >
> > local proc Increment() is local inc = { 0:1,1:2,2:3,3:4,4:5,
> > 5:6,6:7,7:8,8:9,9:0 } counter0 = inc{counter0} if
> > equal(counter0, 0) counter1 = inc{counter1} if equal(counter1,
> > 0) counter2 = inc{counter2} if equal(counter2, 0)
> > counter3 = inc{counter3} end end end local c = "" foreach
> > d in [counter3, counter2, counter1, counter0] if not equal(d, 0)
> > or not equal(c, "") c = c & d end end return cend
> >
> > proc InitMath_F1(a, b) is if equal(a, "9999") return end
> > Add1{a} = b Sub1{b} = a InitMath_F1(b, Increment())end
> > proc InitMath() is counter0 = 0 counter1 = 0 counter2 = 0
> > counter3 = 0 InitMath_F1(0, Increment())end
> >
> > proc Add(a, b) is if equal(a, 0) return b end if equal(b, 0)
> > return a end if equal(a, 1) return Add1{b} end if equal(b, 1)
> > return Add1{a} end return Add1{Add(a, Sub1{b})}end
> >
> > proc Sub(a, b) is if equal(a, 0) return b end if equal(b, 0)
> > return a end if equal(a, 1) return Sub1{b} end if equal(b, 1)
> > return Sub1{a} end return Sub1{Sub(a, Sub1{b})}end
> >
> > InitMath()write("99 - 40 is " & Sub(99, 40), CR)write("6 - 4 is " &
> > Sub(6, 4), CR)write("3 + 2 is " & Add(2, 3), CR)
> --
> Olaf Wagner -- elego Software Solutions GmbH
> Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
> phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95
> http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
> Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194
>
 		 	   		  


More information about the M3devel mailing list