1. RE: Standard Euphoria Library Project
- Posted by Chris Bensler <bensler at mailops.com> Feb 06, 2001
- 437 views
- Last edited Feb 07, 2001
First and foremost.. I propose a StdSeq.lib.. IE.. splice(Seq,Subs) -return a sequence with the specified subscripts removed. dimension_seq(Subs,Dims,Value) -initialize a sequence to the specified number of layers and subscripts with specified value. There are many more.. but I don't have time to write now. Chris Jeffrey Fielding wrote: > I just created a project on sourceforge for a standard library of > include files for Euphoria (in addition to the ones that come with the > interpreter). I think that by creating such a library, we could solve > many of the namespace problems, encourage code reuse, and create some > examples of good Euphoria code for newbies to learn from. So check it > out at http://sourceforge.net/projects/standardeu/ > > I haven't put up any files yet. If anyone wants to help, please do. > Here's the list of stuff that needs to be done: > * propose routines that should go in the library, and an API to go with > them > * write the routines > * write docs > > And when that's done, people need to use it. Right now, many programs > (and worse, include files) redeclare functions that are used over and > over again. Not only is this a waste of time when one can just include a > pre-written set of functions, but it can cause namespace conflicts as > well. People have been complaining about namespaces in Euphoria, but I > think that most of the problems could be solved by not redeclaring > commonly used functions. > > Jeff Fielding > JJProg at cyberbury.net >
2. RE: Standard Euphoria Library Project
- Posted by Chris Bensler <bensler at mailops.com> Feb 07, 2001
- 417 views
David Cuny wrote: <SNIP> > function remove( integer i, sequence s) > -- remove ith element from s > return s[1..i-1] & s[i+1..length(s)] > end function <SNIP> What if the user tries to remove the first or last item? i would end up being 0 or greater than the length of the sequence.. Yeah you could say that it is up to the user to determine that, but if it's going to be in a StdLib, it should be fool proof and robust.. I use this.. function splice(sequence s, integer i) if i=1 then return s[2..length(s)] elsif i=length(s) then return s[1..i-1] else return s[1..i-1] & s[i+1..length(s)] end function any value passed to i will be handled.. if i is out of bounds, than EU will catch it.. This brings up a Q i have.. what is faster.. storing the length of the seqeunce, or just using length()? Chris
3. RE: Standard Euphoria Library Project
- Posted by Kat <gertie at PELL.NET> Feb 07, 2001
- 402 views
On 7 Feb 2001, at 5:06, Chris Bensler wrote: > > David Cuny wrote: > > <SNIP> > > function remove( integer i, sequence s) > > -- remove ith element from s > > return s[1..i-1] & s[i+1..length(s)] > > end function > <SNIP> > > What if the user tries to remove the first or last item? > i would end up being 0 or greater than the length of the sequence.. > > Yeah you could say that it is up to the user to determine that, but if > it's going to be in a StdLib, it should be fool proof and robust.. > > I use this.. > > function splice(sequence s, integer i) > if i=1 then return s[2..length(s)] > elsif i=length(s) then return s[1..i-1] > else return s[1..i-1] & s[i+1..length(s)] > end function > > any value passed to i will be handled.. if i is out of bounds, than EU > will catch it.. What if the passed sequence is "" ? > This brings up a Q i have.. what is faster.. storing the length of the > seqeunce, or just using length()? I think Robert said getting the length of the seq is as fast as getting the first element of the seq. The seq attribute data is stored, such as the length is stored in a basic string as the [0] byte. Kat
4. RE: Standard Euphoria Library Project
- Posted by Chris Bensler <bensler at mailops.com> Feb 07, 2001
- 400 views
You shouldn't be allowed to try and access an out of bounds subscript.. It may not crash, but why would you want it to do that? IMHO, it should crash.. that's what error checking is for.. Chris Fam. Nieuwenhuijsen wrote: > > David Cuny wrote: > > > > <SNIP> > > > function remove( integer i, sequence s) > > > -- remove ith element from s > > > return s[1..i-1] & s[i+1..length(s)] > > > end function > > <SNIP> > > > > What if the user tries to remove the first or last item? > > i would end up being 0 or greater than the length of >the sequence.. > > Yes, *but* Euphoria won't crash. When you slice from one above the > length of > the sequence or when you slice to zero it will return an empty seq > rather > than crash. > > Come on people. This is trivial beginners stuff. > > Ralf N. > nieuwen at xs4all.nl > >
5. RE: Standard Euphoria Library Project
- Posted by Chris Bensler <bensler at mailops.com> Feb 07, 2001
- 412 views
Kat wrote: > > What if the passed sequence is "" ? > Hehe oops.. Revised.. function splice(sequence s, integer i) if length(s)=0 then return s elsif i=1 then return s[2..length(s)] elsif i=length(s) then return s[1..i-1] else return s[1..i-1] & s[i+1..length(s)] end function > I think Robert said getting the length of the seq is as fast as getting > the first element of > the seq. The seq attribute data is stored, such as the length is stored > in a basic string > as the [0] byte. > Actually I just did a little speed test... In the case of my function here.. The speed is identical.. IMHO, length() is faster because predefining it requires extra calls.. I tried a different test too.. and it worked out to be just slightly faster.. I made a two for loops with 100,000,000 iterations, one used length(), the other used the predefined variable.. (defined outside the loop).. I made 5 calls to the sequence length in each for loop.. The prior was faster on every attempt by about 1mS.. averaging 36mS for the ENTIRE loop, where the latter averaged 37mS on my comp.. I think this is because EUdoesn't have to look as far into the look up table for length() as it does for the variable.. Chris {:o)
6. RE: Standard Euphoria Library Project
- Posted by Chris Bensler <bensler at mailops.com> Feb 07, 2001
- 409 views
DOH!! Don't think I actually ever TRIED to see if it works or not before!! To me it just seems irrational that it WOULD work.. it's an invalid subscript.. But to my amazement it does!! Foolish me.. Chris {;oP DUH! Chris Bensler wrote: > You shouldn't be allowed to try and access an out of bounds subscript.. > It may not crash, but why would you want it to do that? IMHO, it should > crash.. that's what error checking is for.. > > Chris > > Fam. Nieuwenhuijsen wrote: > > > David Cuny wrote: > > > > > > <SNIP> > > > > function remove( integer i, sequence s) > > > > -- remove ith element from s > > > > return s[1..i-1] & s[i+1..length(s)] > > > > end function > > > <SNIP> > > > > > > What if the user tries to remove the first or last item? > > > i would end up being 0 or greater than the length of >the sequence.. > > > > Yes, *but* Euphoria won't crash. When you slice from one above the > > length of > > the sequence or when you slice to zero it will return an empty seq > > rather > > than crash. > > > > Come on people. This is trivial beginners stuff. > > > > Ralf N. > > nieuwen at xs4all.nl > > > >
7. RE: Standard Euphoria Library Project
- Posted by Brian Broker <bkb at cnw.com> Feb 07, 2001
- 418 views
FYI: this is straight out of our friendly refman doc: You can delete element i of any sequence s by concatenating the parts of the sequence before and after i: s = s[1..i-1] & s[i+1..length(s)] This works even when i is 1 or length(s), since s[1..0] is a legal empty slice, and so is s[length(s)+1..length(s)]. (see sections 2.2.6 and 2.2.7) -- Brian Chris Bensler wrote: > DOH!! > Don't think I actually ever TRIED to see if it works or not before!! > > To me it just seems irrational that it WOULD work.. it's an invalid > subscript.. > > But to my amazement it does!! > > Foolish me.. > > Chris {;oP DUH! > > Chris Bensler wrote: > > You shouldn't be allowed to try and access an out of bounds subscript.. > > It may not crash, but why would you want it to do that? IMHO, it should > > crash.. that's what error checking is for.. > > > > Chris > > > > Fam. Nieuwenhuijsen wrote: > > > > David Cuny wrote: > > > > > > > > <SNIP> > > > > > function remove( integer i, sequence s) > > > > > -- remove ith element from s > > > > > return s[1..i-1] & s[i+1..length(s)] > > > > > end function > > > > <SNIP> > > > > > > > > What if the user tries to remove the first or last item? > > > > i would end up being 0 or greater than the length of >the sequence.. > > > > > > Yes, *but* Euphoria won't crash. When you slice from one above the > > > length of > > > the sequence or when you slice to zero it will return an empty seq > > > rather > > > than crash. > > > > > > Come on people. This is trivial beginners stuff. > > > > > > Ralf N. > > > nieuwen at xs4all.nl
8. RE: Standard Euphoria Library Project
- Posted by Kat <gertie at PELL.NET> Feb 07, 2001
- 406 views
On 7 Feb 2001, at 10:54, Brian Broker wrote: > FYI: this is straight out of our friendly refman doc: > > You can delete element i of any sequence s by concatenating the parts of > the sequence before and after i: > > s = s[1..i-1] & s[i+1..length(s)] But this would crash for me, with that error about nothing being assigned to s to get the length of. I am using v2.2, the complete edition, according to Exw. Kat > > This works even when i is 1 or length(s), since s[1..0] is a legal empty > slice, and so is s[length(s)+1..length(s)]. > > (see sections 2.2.6 and 2.2.7) > > -- Brian > > Chris Bensler wrote: > > DOH!! > > Don't think I actually ever TRIED to see if it works or not before!! > > > > To me it just seems irrational that it WOULD work.. it's an invalid > > subscript.. > > > > But to my amazement it does!! > > > > Foolish me.. > > > > Chris {;oP DUH! > > > > Chris Bensler wrote: > > > You shouldn't be allowed to try and access an out of bounds subscript.. > > > It may not crash, but why would you want it to do that? IMHO, it should > > > crash.. that's what error checking is for.. > > > > > > Chris > > > > > > Fam. Nieuwenhuijsen wrote: > > > > > David Cuny wrote: > > > > > > > > > > <SNIP> > > > > > > function remove( integer i, sequence s) > > > > > > -- remove ith element from s > > > > > > return s[1..i-1] & s[i+1..length(s)] > > > > > > end function > > > > > <SNIP> > > > > > > > > > > What if the user tries to remove the first or last item? > > > > > i would end up being 0 or greater than the length of >the sequence.. > > > > > > > > Yes, *but* Euphoria won't crash. When you slice from one above the > > > > length of > > > > the sequence or when you slice to zero it will return an empty seq > > > > rather > > > > than crash. > > > > > > > > Come on people. This is trivial beginners stuff. > > > > > > > > Ralf N. > > > > nieuwen at xs4all.nl > >
9. RE: Standard Euphoria Library Project
- Posted by Brian Broker <bkb at cnw.com> Feb 07, 2001
- 434 views
Kat, Please tell me if this program works, or if you get an error about nothing being assigned to 'test'. It works for me so if it doesn't work for you, then your Euphoria is broken... -- save as 'remove.ex' or something like that sequence test test = "Kat" function remove( integer i, sequence s ) -- remove ith element from s return s[1..i-1] & s[i+1..length(s)] end function for i = 1 to length( test ) do puts( 1, remove( i, test ) & "\n" ) end for ------------------------------------- eof You should see: at Kt Ka -- Brian Kat wrote: > On 7 Feb 2001, at 10:54, Brian Broker wrote: > > > FYI: this is straight out of our friendly refman doc: > > > > You can delete element i of any sequence s by concatenating the parts of > > > > the sequence before and after i: > > > > s = s[1..i-1] & s[i+1..length(s)] > > But this would crash for me, with that error about nothing being > assigned to s to get > the length of. I am using v2.2, the complete edition, according to Exw. > > Kat
10. RE: Standard Euphoria Library Project
- Posted by Kat <gertie at PELL.NET> Feb 07, 2001
- 406 views
On 7 Feb 2001, at 14:23, Brian Broker wrote: > Kat, > > Please tell me if this program works, or if you get an error about > nothing being assigned to 'test'. It works for me so if it doesn't > work for you, then your Euphoria is broken... > > -- save as 'remove.ex' or something like that > sequence test > test = "Kat" > > > function remove( integer i, sequence s ) > -- remove ith element from s > return s[1..i-1] & s[i+1..length(s)] > end function > > for i = 1 to length( test ) do > puts( 1, remove( i, test ) & "\n" ) > end for > ------------------------------------- eof > > You should see: > at > Kt > Ka I'm puzzled, i saw those. And i added a few line to the bottom: include get.e integer key sequence test test = "Kat" function remove( integer i, sequence s ) -- remove ith element from s return s[1..i-1] & s[i+1..length(s)] end function for i = 1 to length( test ) do puts( 1, remove( i, test ) & "\n" ) end for ------------------------------------- eof key = wait_key() test = "" puts(1,"\n"&sprintf("%d",length(test))&"\n") puts(1," ^ printed length of test\n") key = wait_key() and i got the length of test = 0, which is correct, but it has been crashing, i swear! Kat
11. RE: Standard Euphoria Library Project
- Posted by Al Getz <Xaxo at aol.com> Feb 07, 2001
- 426 views
Hi Kat, I ran your program: > include get.e > integer key > sequence test > test = "Kat" > > > function remove( integer i, sequence s ) > -- remove ith element from s > return s[1..i-1] & s[i+1..length(s)] > end function > > for i = 1 to length( test ) do > puts( 1, remove( i, test ) & "\n" ) > end for > ------------------------------------- eof > > key = wait_key() > > test = "" > puts(1,"\n"&sprintf("%d",length(test))&"\n") > > puts(1," ^ printed length of test\n") > key = wait_key() > and got the following output: at Kt Ka 0 ^ printed length of test So it seems the program runs just fine. Whats wrong when you run it? --Al
12. RE: Standard Euphoria Library Project
- Posted by Al Getz <Xaxo at aol.com> Feb 07, 2001
- 414 views
Hi again Kat, I did notice a few problems with the function: function remove( integer i, sequence s ) -- remove ith element from s return s[1..i-1] & s[i+1..len] end function For example, passing the null sequence (s="") will cause an error. The possible error situations are 1. null sequence 2. i<=0 3. i>length of the sequence It seems a little range checking would be worthwhile: --improved 'remove()' function: function remove( integer i, sequence s ) -- remove ith element from s integer len len=length(s) if len>0 then --handles null sequence if i>0 then --handles i<=0 if i>len then --handles i greater then the length of the seq. return s else return s[1..i-1] & s[i+1..len] end if end if end if return "" end function This should take care of most problems associated with removing specific elements of a sequence. Good luck with it. --Al
13. RE: Standard Euphoria Library Project
- Posted by Humberto Yeverino <codehead78 at YAHOO.COM> Feb 07, 2001
- 400 views
You're still missing a couple of cases: function remove(integer n, sequence s) integer len len = length(s) if len>1 then if n=1 then return s[2..len] elsif n=len then return s[1..len-1] end if return s[1..n-1] & s[n+1..len] end if return {} end function That covers it. -Humberto > --improved 'remove()' function: > > function remove( integer i, sequence s ) > -- remove ith element from s > integer len > > len=length(s) > if len>0 then --handles null sequence > if i>0 then --handles i<=0 > if i>len then --handles i greater then the > length of the seq. > return s > else > return s[1..i-1] & s[i+1..len] > end if > end if > end if > return "" > end function > > This should take care of most problems associated > with removing > specific elements of a sequence. > > Good luck with it. > --Al > >
14. RE: Standard Euphoria Library Project
- Posted by Irv Mullins <irvm at ellijay.com> Feb 07, 2001
- 402 views
On Wed, 07 Feb 2001, Humberto wrote: > You're still missing a couple of cases: > > function remove(integer n, sequence s) > integer len > len = length(s) > if len>1 then > if n=1 then -- not needed > return s[2..len] -- not needed > elsif n=len then -- not needed > return s[1..len-1] -- not needed > end if > return s[1..n-1] & s[n+1..len] > end if > return {} > end function > > That covers it. You've somewhat underestimated Euphoria's abilities - all you really need is: sequence s function remove(integer x, sequence s) if x < 1 or x > length(s) then return s end if return s[1..x-1]&s[x+1..length(s)] end function s = "123" for i = -1 to 5 do printf(1, "Removing %d = %s\n", {i,remove(i,s)}) end for Example run: Removing -1 = 123 Removing 0 = 123 Removing 1 = 23 Removing 2 = 13 Removing 3 = 12 Removing 4 = 123 Removing 5 = 123 Regards, Irv
15. RE: Standard Euphoria Library Project
- Posted by Humberto Yeverino <codehead78 at YAHOO.COM> Feb 07, 2001
- 396 views
- Last edited Feb 08, 2001
For some reason I thought reverse slicing would cause a crash... thanks, -Humberto --- Irv Mullins <irvm at ellijay.com> wrote: .. > You've somewhat underestimated Euphoria's abilities > - all you really need is: > sequence s > > function remove(integer x, sequence s) > if x < 1 or x > length(s) then return s > end if > return s[1..x-1]&s[x+1..length(s)] > end function > > s = "123" > > for i = -1 to 5 do > printf(1, "Removing %d = %s\n", {i,remove(i,s)}) > end for > > Example run: > Removing -1 = 123 > Removing 0 = 123 > Removing 1 = 23 > Removing 2 = 13 > Removing 3 = 12 > Removing 4 = 123 > Removing 5 = 123 > > Regards, > Irv > >
16. RE: Standard Euphoria Library Project
- Posted by Al Getz <Xaxo at aol.com> Feb 07, 2001
- 421 views
- Last edited Feb 08, 2001
Irv Mullins wrote: > You've somewhat underestimated Euphoria's abilities - all you really > need is: > sequence s > > function remove(integer x, sequence s) > if x < 1 or x > length(s) then return s > end if > return s[1..x-1]&s[x+1..length(s)] > end function > Looks good to me Irv. Mainly, when using any function like this, some sort of range checking is always desirable in order to reduce errors that cause the program to hault. Good luck with it. --Al
17. RE: Standard Euphoria Library Project
- Posted by Kat <gertie at PELL.NET> Feb 07, 2001
- 408 views
- Last edited Feb 08, 2001
On 7 Feb 2001, at 16:42, Al Getz wrote: > Hi Kat, > I ran your program: > > > include get.e > > integer key > > sequence test > > test = "Kat" > > > > > > function remove( integer i, sequence s ) > > -- remove ith element from s > > return s[1..i-1] & s[i+1..length(s)] > > end function > > > > for i = 1 to length( test ) do > > puts( 1, remove( i, test ) & "\n" ) > > end for > > ------------------------------------- eof > > > > key = wait_key() > > > > test = "" > > puts(1,"\n"&sprintf("%d",length(test))&"\n") > > > > puts(1," ^ printed length of test\n") > > key = wait_key() > > > > and got the following output: > > at > Kt > Ka > > 0 > ^ printed length of test > > So it seems the program runs just fine. Whats wrong when you run it? Like i said, it runs fine, but it has crashed in other code when i did length(emptysequence) . Kat
18. RE: Standard Euphoria Library Project
- Posted by mtsreborn at yahoo.com Feb 07, 2001
- 432 views
- Last edited Feb 08, 2001
Heh? I use length({}) all the time, and never had it crash on me. I use it frequently in a language library to see if an include file wich has being parsed doesn't contain any code. BTW, that reminds me, if anyone wants this 'language.e' library, tell me and I will post it to the list. It's perfect for creating programming languages, as the boring and tedious crap like parsing and getting include files is allready done for you. I made it cos I got sick of rewriting a damned parser in every language tool I wrote, and try to reinvent an include file system. For example, the first time I wrote a language tool, I was breaking my head over how to write an include file system. Yeah I know, it sounds easy at first glance, but consider a file called a.ex wich includes l.e, wich inturn includes d.e and c.e, wich all include o.e, etc. So anyways, anyone needing this small library, especially suited for implementing Euphoria translators and interpreters, ask and I will post it to the list. Mike The Spike --- Kat <gertie at PELL.NET> wrote: > On 7 Feb 2001, at 16:42, Al Getz wrote: > > > Hi Kat, > > I ran your program: > > > > > include get.e > > > integer key > > > sequence test > > > test = "Kat" > > > > > > > > > function remove( integer i, sequence s ) > > > -- remove ith element from s > > > return s[1..i-1] & s[i+1..length(s)] > > > end function > > > > > > for i = 1 to length( test ) do > > > puts( 1, remove( i, test ) & "\n" ) > > > end for > > > ------------------------------------- eof > > > > > > key = wait_key() > > > > > > test = "" > > > puts(1,"\n"&sprintf("%d",length(test))&"\n") > > > > > > puts(1," ^ printed length of test\n") > > > key = wait_key() > > > > > > > and got the following output: > > > > at > > Kt > > Ka > > > > 0 > > ^ printed length of test > > > > So it seems the program runs just fine. Whats > wrong when you run it? > > Like i said, it runs fine, but it has crashed in > other code when i did > length(emptysequence) . > > Kat > > >
19. RE: Standard Euphoria Library Project
- Posted by Chris Bensler <bensler at mailops.com> Feb 09, 2001
- 417 views
Ahahah HEEMMM!! *Cough* *Cough* Wrapper for OpenGL : Open GL : Creator: MTS !! EuSDL : DirectX : Creator: Russel Davis Jarod : SVGA : Creator: Mic EuAllegro : Allegro : Creator: Ray Smith Morphit for EU : Morphit 3D : Creator: Mark Brown/Todd Riggins Exotica : DirectX : Creator: Todd Riggins SVGA for Linux : SVGA : Creator: Pete Eberlein OpenGL for EU : OpenGL : Creator: Mic GLUT Wrapper for EU : OpenGL..GLUT : Creator: Mic NIEL : SVGA : Creator: Pete Eberlein ETC... ETC... ETC... ETC... How many options do you need? If someone's too lazy to look for what's available, then too bad for them.. If what's there isn't satisfactory, then code it yerself! Most of these people spent a lot of time working on these libs.. If you don't like it. Either you don't use em, code yer own, or you find something that IS satisfactory.. Simple as that.. I don't think we really NEED more graphix libs, but if people are willing to do so, then good. The more the merrier. Better options.. Keep in mind... Graphix Libs are complex.. most aren't willing to take the time to learn them in order to code their first game.. especially when they are still learning the language itself.. Where's your games oh master coder? You should be able to whip one up in a couple of minutes for us.. should have a few up there by now.. Show us how slow EU is for coding 3D.. use yer own OpenGL even.. should super fast, considering it's an authentic MTS product. Instead of griping.. get yer fingers dirty and produce something usefull instead of just spit.. You have some good things to say, but when tainted with all your vulgarity and childish bickering, people tend to NOT notice.. That, and they simply don't care.. SHOW us what you can do, instead of TELLING us.. Maybe people will start to give you credit where it's due.. Chris Mike The Spike wrote: > > --- Jeffrey Fielding <JJProg at CYBERBURY.NET> wrote: > > MTS - I fished your reply out of the trash. Your > > organizational scheme sounds > > like an okay start, though I'd add some files for > > more specific routines, and > > some of your proposed files might be outside the > > scope of this project. If you > > want to contribute to this project, please > > contribute logical and useful stuff > > like this, not profanity-riddled nonsense. > > > > Thanks, > > Jeff Fielding > > Wha? > You like that scheme? > Well, it's better than SeqLib.e, GFX.e and StrTok.e or > some shit like that. > > I think if we wanna do something usefull with this > project, we shouldn't all provide a sequence routine > library or some lame shit like that. > We could take advantage of this oppurtunity to > actually code all those libraries we wanted for such a > long time, but weren't able to code on our own. > > A multiplatform GUI would finally give our Euphoria > programs a uniform look on all platforms. > Maybe a LLama/Win32lib hybrid? > > And Mic and Jiri could spew out some fast 3D graphics > rotuines so Euphoria games don't look like mode 13h > Space Invaders clones. > The games I saw in Euphoria were mostly clones from > old arcade games. > But that's not fair, since those arcade games were a > few K in size and coded in ASM back in the 70s. > Like this latest RPG is saw, what was it, you know, > that RPG with the .bat file that points to something > wrong, well, that's a 320*200*256 game written in a > 32-Bit high performance programming language, with > optimising compiler support. > If it was a 160*144*256 game, it could be running on > the damned Gameboy (in HighColor mode). > When are we gonna see some Quake clones in Eu? > The reason why we aren't seeing any right now, is > because of a lack of multimedia libraries in Euphoria. > C, for example, has access to OpenGL, Direct X, > Allegro, etc. automagically. Just include a few files > and you're set. > > > Mike The Spike > >