### 1. Suggested Extension to Euphoria language

```I was doing what I call "concept coding" today, and found that
a lot of what I was doing for the project involved building up
sequences from selected elements of other sequences,
frequently within loops of various types.

It occurred to me that an extension of the slice concept might
come in useful here, such that if the subscript were a
sequence of integers, it would have the effect of selecting
those items in the sequence in the corresponding positions.
Under such an extension, a[3..6] (legal syntax) and
a[{3,4,5,6}] (illegal, but proposed) would be equivalent - but
one could also write a[{1,3,4,6,8,12}] and get back a sequence
containing only those elements, in that order.  This would
also naturally open up the possibilities of "reverse slices"
(i.e., a[6..3] (illegal syntax)) in the form a[{6,5,4,3}].  As
it is, to process these "extended slices", I must place the
desired sequence in a variable, and then loop on the index
into the variable to build the result sequence:

index_seq = {1,2,3,5,8}
b = {}
for i = 1 to length(index_seq)
b = append(b,a[index_seq[i]])
end for

whereas under the proposed sequence I could say

b = a[index_seq]

I find this extension to be no less intuitive than the current
sequential slice syntax (b = a[3..6]), and, as indicated, it
seems to me to be a logical extension.

N.B. for those who are curious, "concept coding" means that
the code is essentially the core routines with hard-coded
values (which should be parameters) to determine if the lines
that I am thinking along are appropriate to solve the problem
I am working on.

=========================================================================
Jeff Zeitlin                                      jeff.zeitlin at execnet.com
---
~ OLXWin 1.00b ~ War on drugs?!?! Put ME on the FRONT LINES!!!!
```

### 2. Re: Suggested Extension to Euphoria language

```On Wed, 26 Feb 1997, JEFF ZEITLIN wrote:
>   N.B. for those who are curious, "concept coding" means that
>   the code is essentially the core routines with hard-coded
>   values (which should be parameters) to determine if the lines
>   that I am thinking along are appropriate to solve the problem
>   I am working on.

Cool!  Someone else who makes up terminology to fit what he's doing, then
explains it like EVERYONE uses the term!  =)  I thought I was the only
one who does that.  Of course, if you explain it to enough people,
everyone WILL use the term... ;)

My favorite coined term to date is "Automagic Processing."  that's a big
aspect of "Simultaneous Event Driven Programming."

Michael Packard
Lord Generic Productions
lgp at exo.com http://exo.com/~lgp
A Crash Course in Game Design and Production
http://exo.com/~lgp/euphoria
```

### 3. Suggested Extension to Euphoria language

```Hello Jef,

I think that your proposed extension of the Euphoria language is
unnecessary, since what you want can easily be done by a small global
function.

My automagic proposal is:

function extract(sequence from, sequence index)
-- returns indexed elements from a sequence
sequence into
into = repeat(0, length(index))
if index[length(index)] > length(from) then     -- test for bad
indexing
return 0
end if
for magic = 1 to length(into) do        -- or to length(index),
that's the same
into[magic] = from[index[magic]]
end for
return into
end function    -- extract

-- test it
---------------------------------------------------------------------------
------------------------

sequence a, index_seq
object b

a = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
index_seq = {3, 5, 7, 6, 9}     -- the order is unimportant

b = extract(a, index_seq)       -- instead of b = a[index_seq]
? b
while get_key() = -1 do
end while
---------------------------------------------------------------------------
------------------------------------

The only problem is maybe somewhat less speed then an inbuild function, but
there are so many things that we probably wanted to have build-in, like for
instance pause(), wait(), input(), prompt(), round() etc. I think that
small functions and procedures you write and then put to use as global in
an include file, can contribute a lot to the use of the language.

This ends my automagic soulution proposal,

Bye,

```

### 4. Suggested Extension to Euphoria language

```Thanks to Jeff Zeitlin for his suggestion.

I've received many suggestions for defining what it would
mean to subscript a sequence with a sequence:

1. Jeff's idea (it's done like this in APL):

s[{a,b,c}] is {s[a],s[b],s[c]}

2. Someone else suggested (useful for tree structures of unknown depth):

s[{a,b,c}] is s[a][b][c]

3. Someone else suggested (the database people would like it):

s["Fred"] is the Euphoria object associated with "Fred" e.g.
s["Fred"] = 99
s["Dave"] = 27
s["George"] = {1,2,3}

Euphoria would try to look up "Fred" in s
in some efficient way (linear search, hashing, whatever).
If "Fred" couldn't be found it might fail, or perhaps
return some special value (what value?).

So far I haven't been convinced that any of the above are really worth it,
since you can achieve the same effect fairly easily using the
existing language. Plus the fact there are at least three choices
makes it difficult to confidently commit to one of them.
The main reason is I don't want to make the language more complicated
without good reason.

Regards,
Rob Craig
Rapid Deployment Software
```

### 5. Re: Suggested Extension to Euphoria language

```What I wanna see is bob=dave[1..5][2..28]  It's annoying to have to do a
for-end for construction for that every time.

bob=repeat(0,5)
for i = 1 to 5 do
bob[i]=dave[i][2..28]
end for

I do this kinda thing CONSTANTLY working with images and virtual screens.

Michael Packard
Lord Generic Productions
lgp at exo.com http://exo.com/~lgp
A Crash Course in Game Design and Production
http://exo.com/~lgp/euphoria
```

### 6. Re: Suggested Extension to Euphoria language

```About this list slicing proposed extension. I contacted Rob Craig couple
of weeks ago. I told him of a facility in the programming language
called Miranda which is called 'List Comprehension' and is what you

This is a truly powerful feature which will make composing lists
(sequences) far faster and easier. I hope Rob has looked into it.

Matt
--
u5ms at csc.liv.ac.uk
http://www.csc.liv.ac.uk/~u5ms/
```