Re: Euphoria 4.0.1

new topic     » goto parent     » topic index » view thread      » older message » newer message
Vinoba said...
mattlewis said...

We're getting close to the planned release of Euphoria 4.0.1 (about three weeks away)....

If anyone has any other issues, now is the time to speak up, so that we might be able get a fix .....

Matt

Matt:

1. The facility in Math to be able to use a single value against a sequence can only be accomplished via use of Object type on both sides of the Math function. Is there no other way of allowing a sequence against a single value? In other words, can we not allow the low level functions themselves decide that one side is a sequence and the other a single element and automatically execute appropriately?

2. How do we convert a single element value to a sequence?

I am posting examples of the above two situations as treated by APL. This might have been considered and discarded by RC years ago. Anyway, I thought I would try and find out.

⍝ Examples start here.

A ← ⍳10 ⍝ here we create a sequence of 1 to 10

A ⍝ Show A

1 2 3 4 5 6 7 8 9 10


Example:

include std/sequence.e 
sequence A 
 
A = series(1, 1, 10) 
 
? A 
 
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 

Reference: http://openeuphoria.org/docs/std_sequence.html#_2498_series


Vinoba said...

A รท 2 ⍝ here we divide a sequence by a single value 2 ( a scalar)

0.5 1 1.5 2 2.5 3 3.5 4 4.5 5


Example:

? A / 2 
 
{0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5} 

This has ALWAYS been a part of Euphoria. It's a long standing-feature and a strong selling point of the language, otherwise Euphoria would just be "Pascal Lite". Reference: http://openeuphoria.org/docs/lang_def.html#_8_operationsonsequences


Vinoba said...

B ← 43.89

B

43.89

⍴ B ⍝ Shape of B is a null

C ← ,B ⍝ Ravel function (,) Convert from single to sequence and store in C

⍴ C ⍝ Shape of C is a one element sequence

1

⍝ Examples end here.


I'm not sure I understand this last bit, but isn't it just:

object B = 43.89, C 
 
C = {B} 
 
? B 
? C 
 
43.89 
{43.89} 

You can always use atom() or sequence() to determine if something is an atom or a sequence. Reference: http://openeuphoria.org/docs/lang_decl.html#_118_atom
http://openeuphoria.org/docs/lang_decl.html#_119_sequence (Hmm. That could stand to be re-written to describe better what the sequence() function does.)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu