Euphoria Sequence
-
- User
- Posts: 77
- Joined: Thu Jun 20, 2013 5:41 am
- Location: Springerville AZ USA
Euphoria Sequence
I'm scavenging some routines from a program I wrote years ago in the Euphoria language.
Euphoria is not the language for writing professional applications but it really is the best for developing algorithms. Sequences are the reason. Sequences are THE data structure for the humble programmer.
My hope is limited, but a sequence data type would be jaw dropping.
Euphoria is not the language for writing professional applications but it really is the best for developing algorithms. Sequences are the reason. Sequences are THE data structure for the humble programmer.
My hope is limited, but a sequence data type would be jaw dropping.
-
- Addict
- Posts: 1675
- Joined: Sun Dec 12, 2010 12:36 am
- Location: Somewhere in the midwest
- Contact:
Re: Euphoria Sequence
I looked at some quick examples in google.
This looks like a List ??
We can also have Structured Lists, Arrays, Maps and such.
Maybe its more complicated than that, but it looks like you could get the functionality you are looking for by using one of the mentioned things above.
This looks like a List ??
We can also have Structured Lists, Arrays, Maps and such.
Maybe its more complicated than that, but it looks like you could get the functionality you are looking for by using one of the mentioned things above.
-
- User
- Posts: 77
- Joined: Thu Jun 20, 2013 5:41 am
- Location: Springerville AZ USA
Re: Euphoria Sequence
No, it's not a list or a map. You might call it a ragged array. It is a very subtle, elegant data structure.
Any programmer that uses a sequence will fall in love and have their heart broken when they can't use them anymore... seriously.
Any programmer that uses a sequence will fall in love and have their heart broken when they can't use them anymore... seriously.
-
- Addict
- Posts: 1675
- Joined: Sun Dec 12, 2010 12:36 am
- Location: Somewhere in the midwest
- Contact:
Re: Euphoria Sequence
Well you certainly have me curious... what is a "ragged" Array ?
For all intents, the stuff I looked at seemed like the special part was some of the stuff you could do to the data type, as opposed to the data type itself ? (run this algorithm against it, run that, etc)
Where has my understanding gone wrong?
It certainly seems that with a little finaggling, you could probably emulate a Sequence in PureBasic. Although if you need to resize an array you lose the ability to use multiple dimensions.
Using a Dynamic Linked List seems like a more probable solution. Since they can have any number of elements and can also use User Defined Types.
So in a round-about way, you could define your Sequence as a User Defined Type. Then possibly write some helper procedures to manipulate data based on that format ?
Of course I could be very wrong. In which case I will crawl back under my rock
For all intents, the stuff I looked at seemed like the special part was some of the stuff you could do to the data type, as opposed to the data type itself ? (run this algorithm against it, run that, etc)
Where has my understanding gone wrong?
It certainly seems that with a little finaggling, you could probably emulate a Sequence in PureBasic. Although if you need to resize an array you lose the ability to use multiple dimensions.
Using a Dynamic Linked List seems like a more probable solution. Since they can have any number of elements and can also use User Defined Types.
So in a round-about way, you could define your Sequence as a User Defined Type. Then possibly write some helper procedures to manipulate data based on that format ?
Of course I could be very wrong. In which case I will crawl back under my rock

-
- User
- Posts: 77
- Joined: Thu Jun 20, 2013 5:41 am
- Location: Springerville AZ USA
Re: Euphoria Sequence
An array is regular: square, cubed, etc. A ragged array is not.what is a "ragged" Array ?
You might think so, meaning you need to understand Euphoria sequences better. It's a combination of things.you could probably emulate a Sequence in PureBasic
Zach, you are too valuable to be crawling under rocks. Instead, get a copy of Euphoria and look at some of the examples (every examples uses sequences it only has two data types and the other is simply a single number, the atom.)
Version 3 was written by the original author. Version 4 is written by a team.
I was originally going to write my project in Euphoria but the GTK library had a callback problem that didn't allow it to compile (and using an interpreter is not my idea of a professional product for distribution.)
A sequence has no dimensions. It has a length and each item is indexed. Each item can be another sequence of any length. That in turn can contains sequences of any length.
Here's an example of code (not entirely original to me) I'm going to borrow from an old Euphoria project I wrote (my first) and translate into PureBasic...
Code: Select all
temp = {{},{}}
for Index = 1 to 360 do
temp[1] = append(temp[1], sin(Index*PI/180))
temp[2] = append(temp[2], cos(Index*PI/180))
end for
constant sin_lookup = temp[1], cos_lookup = temp[2]
function Rotate(sequence shape, atom facing)
for ndex = 1 to length(shape) do
shape[ndex] = {
(shape[ndex][Xord] * cos_lookup[facing])-(shape[ndex][Yord] * sin_lookup[facing]),
(shape[ndex][Yord] * cos_lookup[facing])+(shape[ndex][Xord] * sin_lookup[facing])}
end for
return shape
end function
shape in this case is just a polygon, but shape could also be a collection of polygons. rotate takes a shape and makes it a new shape point in any of 360 facings.
The thing about a sequence is it can be anything. It's a universal type with no requirement for the programmer to do memory allocation or deallocation. In Euphoria the concept of TYPE is any function you want to validate a sequence.
It's more addicting than crack or sex.
-
- User
- Posts: 77
- Joined: Thu Jun 20, 2013 5:41 am
- Location: Springerville AZ USA
Re: Euphoria Sequence
This is really the key line...
Note that I took parts of a mutable sequence and assigned it to two immutable sequences without having to specify the dimensions of the two constant sequences.
Code: Select all
constant sin_lookup = temp[1], cos_lookup = temp[2]
-
- User
- Posts: 77
- Joined: Thu Jun 20, 2013 5:41 am
- Location: Springerville AZ USA
Re: Euphoria Sequence
Not an issue for a Euphoria sequence.Although if you need to resize an array you lose the ability to use multiple dimensions.
Euphoria actually has some of the same issues as PureBasic in that all programs may have multiple physical files but logically it's just one big file and order matters in both.
I'll just have to keep using PureBasic 'til my ideal language comes along (after I'm six feet under, if even then.)
-
- Addict
- Posts: 1675
- Joined: Sun Dec 12, 2010 12:36 am
- Location: Somewhere in the midwest
- Contact:
Re: Euphoria Sequence
Hmm well. Yes, it is definitely beyond my current level of understanding
We're in the same boat. I guess. My ideal language is probably different from yours, but it consists of one simple concept.
I tell the program to do something in plain English... It does it!
haha

We're in the same boat. I guess. My ideal language is probably different from yours, but it consists of one simple concept.
I tell the program to do something in plain English... It does it!
haha

-
- User
- Posts: 77
- Joined: Thu Jun 20, 2013 5:41 am
- Location: Springerville AZ USA
Re: Euphoria Sequence
Plain English is a nasty Trap. That's how Data got in trouble with the Enterprise holodeck creating the Moriarty character that could beat him!!! You do know that everything you need to know in life was once a Star Trek plot, right?
- Zebuddi123
- Enthusiast
- Posts: 796
- Joined: Wed Feb 01, 2012 3:30 pm
- Location: Nottinghamshire UK
- Contact:
Re: Euphoria Sequence
@ken_anthony does that mean Desi Arnaz and Lucille Ball were aliens ? lol
Zebuddi.
Zebuddi.

malleo, caput, bang. Ego, comprehendunt in tempore
-
- User
- Posts: 77
- Joined: Thu Jun 20, 2013 5:41 am
- Location: Springerville AZ USA
Re: Euphoria Sequence
Not Sure. But I do know Desi was the funny one.
- langinagel
- Enthusiast
- Posts: 131
- Joined: Fri Jan 28, 2005 11:53 pm
- Location: Germany
- Contact:
Re: Euphoria Sequence
Howdy,
besides the Startrek stories, I do not get the grasp for the sequences.
It reminds me on old time MATLAB programming, juggling with vectors. Trying to change a single value in a vector or a field was a then (now hopefully easier) a real pain, that let me get thoughts on working with FORTRAN.
Now the same way: easy way to describe an array...but if you like to change specific values then you might face higher efforts.
In Purebasic now:
array(x,y,z) = whatever.w
or working with element-commands
or for those who like it, juggling with pointers on arrays or lists
From my perspective: the old fashioned way is more deterministic, better understandable.
And: sequences would be far away from the BASIC ANSI/ISO/IEC norm.
a "No, thanks" from my side.
LN
besides the Startrek stories, I do not get the grasp for the sequences.
It reminds me on old time MATLAB programming, juggling with vectors. Trying to change a single value in a vector or a field was a then (now hopefully easier) a real pain, that let me get thoughts on working with FORTRAN.
Now the same way: easy way to describe an array...but if you like to change specific values then you might face higher efforts.
In Purebasic now:
array(x,y,z) = whatever.w
or working with element-commands
or for those who like it, juggling with pointers on arrays or lists
From my perspective: the old fashioned way is more deterministic, better understandable.
And: sequences would be far away from the BASIC ANSI/ISO/IEC norm.
a "No, thanks" from my side.
LN
-
- User
- Posts: 77
- Joined: Thu Jun 20, 2013 5:41 am
- Location: Springerville AZ USA
Re: Euphoria Sequence
If you like arrays, you should love sequences. They can do anything an array can and more.
becomes
Which may look a bit funny if your used to commas, but the power you get in exchange is more than worth training your habit to see it the new way.
For example, what if you just need two of three dimensions? With the array, you always have to deal with Z. With sequences it's just
Using the exact same sequence as above. Which means you could pass the same sequence to a 2D function or a 3D function. You can't do that with an array.
The beauty of a sequence is that is makes algorithms much more elegant. Beauty and elegance are qualities that all good code should have. A lot of programmers will have no idea what I mean by that last sentence. Those that do should be listened to.
Code: Select all
array(x,y,z) = whatever.w
Code: Select all
array[x][y][z] = whatever
For example, what if you just need two of three dimensions? With the array, you always have to deal with Z. With sequences it's just
Code: Select all
array[x][y]
The beauty of a sequence is that is makes algorithms much more elegant. Beauty and elegance are qualities that all good code should have. A lot of programmers will have no idea what I mean by that last sentence. Those that do should be listened to.
-
- User
- Posts: 77
- Joined: Thu Jun 20, 2013 5:41 am
- Location: Springerville AZ USA
Re: Euphoria Sequence
BTW, I caught <a href="http://www.cs.utexas.edu/users/EWD/tran ... .html">the irony of your tagline</a>.
-
- User
- Posts: 77
- Joined: Thu Jun 20, 2013 5:41 am
- Location: Springerville AZ USA
Re: Euphoria Sequence
Well that didn't work. Let me try this: http://www.cs.utexas.edu/users/EWD/tran ... WD340.html