From: dpb on
Henning wrote:
> "dpb" <none(a)non.net> skrev i meddelandet
....

>> Or, a language that supports array slices (such as Fortran or Matlab)...
>> :)
>>
>> sngTest = sngArr(1,:) % Matlab syntax; Fortran is very similar
>>
>> --
>
> Or use the easy way out.
> sngTest(0) = sngArr(1,0)
> sngTest(1) = sngArr(1,1)
>
> If lots of elements.
> For i = 0 to NumElements
> sngTest(i) = sngArr(1,i)
> Next
....

Oh, indeed...take the obvious route. What's the fun in that?

I was just being kinda' snarky... :)

It's been a pet peeve for years of mine that VB w/ all it's user
conveniences never implemented array slice notation. It seems such an
obvious extension for a language intended for rapid development.

--
From: Tom Shelton on
on 8/12/2010, dpb supposed :
> Henning wrote:
>> "dpb" <none(a)non.net> skrev i meddelandet
> ...
>
>>> Or, a language that supports array slices (such as Fortran or Matlab)...
>>> :)
>>>
>>> sngTest = sngArr(1,:) % Matlab syntax; Fortran is very similar
>>>
>>> --
>>
>> Or use the easy way out.
>> sngTest(0) = sngArr(1,0)
>> sngTest(1) = sngArr(1,1)
>>
>> If lots of elements.
>> For i = 0 to NumElements
>> sngTest(i) = sngArr(1,i)
>> Next
> ...
>
> Oh, indeed...take the obvious route. What's the fun in that?
>
> I was just being kinda' snarky... :)
>
> It's been a pet peeve for years of mine that VB w/ all it's user conveniences
> never implemented array slice notation. It seems such an obvious extension
> for a language intended for rapid development.

It's funny, but I can't think of any statically compiled language that
implements array slice functionality. It's seem to only be in the
dynamic languages - Perl, Python, Ruby, etc.....

--
Tom Shelton


From: dpb on
Tom Shelton wrote:
....

> It's funny, but I can't think of any statically compiled language that
> implements array slice functionality. It's seem to only be in the
> dynamic languages - Perl, Python, Ruby, etc.....

Fortran for at least one...requires F90+, but that's now the norm and is
20+ years old now...

Some examples; there are many other ways for usage as well...

> Array assignment is permitted when the array expression on the right
> has the same shape as the array variable on the left, or the expression
> on the right is a scalar.
> If the expression is a scalar, and the variable is an array, the
> scalar value is assigned to every element of the array.
> If the expression is an array, the variable must also be an array.
> The array element values of the expression are assigned (element by
> element) to corresponding elements of the array variable.
>
> A many-one array section is a vector-valued subscript that has two or
> more elements with the same value. In intrinsic assignment, the
> has the same shape as the array variable on the left, or the expression
> on the right is a scalar.

>
> Examples
>
> In the following example, X and Y are arrays of the same shape:
>
> X = Y
>
> The corresponding elements of Y are assigned to those of X element by
> element; the first element of Y is assigned to the first element of X,
> and so forth. The processor can perform the element-by-element
> assignment in any order.
>
> The following example shows a scalar assigned to an array:
>
> B(C+1:N, C) = 0
>
> This sets the elements B (C+1,C), B (C+2,C),...B (N,C) to zero.
>
> The following example causes the values of the elements of array A to
> be reversed:
>
> REAL A(20)
> ...
> A(1:20) = A(20:1:-1)
>
....

> A vector subscript is a one-dimensional (rank one) array of integer
> values (within the declared bounds for the dimension) that selects a
> section of a whole (parent) array. The elements in the section do not
> have to be in order and the section can contain duplicate values.
>
> For example, A is a rank-two array of shape (4,6). B and C are
> rank-one arrays of shape (2) and (3), respectively, with the following
> values:
> B = (/1,4/) ! Syntax (/.../) denotes an array constructor
> C = (/2,1,1/) ! This constructor produces a many-one array section
>
> Array section A(3,B) consists of elements A(3,1) and A(3,4). Array
> section A(C,1) consists of elements A(2,1), A(1,1), and A(1,1). Array
> section A(B,C) consists of the following elements:
> A(1,2) A(1,1) A(1,1)
> A(4,2) A(4,1) A(4,1)
> An array section with a vector subscript that has two or more
> elements with the same value is called a many-one array section. For
> example:
> REAL A(3, 3), B(4)
> INTEGER K(4)
> ! Vector K has repeated values
> K = (/3, 1, 1, 2/)
> ! Sets all elements of A to 5.0
> A = 5.0
> B = A(3, K)
>
> The array section A(3,K) consists of the elements:
> A(3, 3) A(3, 1) A(3, 1) A(3, 2)

--
From: Tom Shelton on
It happens that dpb formulated :
> Tom Shelton wrote:
> ...
>
>> It's funny, but I can't think of any statically compiled language that
>> implements array slice functionality. It's seem to only be in the dynamic
>> languages - Perl, Python, Ruby, etc.....
>
> Fortran for at least one...requires F90+, but that's now the norm and is 20+
> years old now...

Ok... There's one. I'm not familar with fortran :)

--
Tom Shelton


From: dpb on
Tom Shelton wrote:
> It happens that dpb formulated :
>> Tom Shelton wrote:
>> ...
>>
>>> It's funny, but I can't think of any statically compiled language
>>> that implements array slice functionality. It's seem to only be in
>>> the dynamic languages - Perl, Python, Ruby, etc.....
>>
>> Fortran for at least one...requires F90+, but that's now the norm and
>> is 20+ years old now...
>
> Ok... There's one. I'm not familar with fortran :)

BASIC w/ Do...EndDo instead of For...Next

Syntax is very similar to BASIC; except for rather arcane features such
as Fortran pointers (which aren't needed for anything ordinary as are
for arrays, etc., in C or C-like languages but are handy for things like
linked lists, etc.), syntax would mostly be readily understandable by a
competent BASIC/VB user.

_Extremely_ useful w/ VB as the backend for compute-intensive stuff
since BASIC (and VB) inherited column-major array order from FORTRAN
(now officially Fortran). The other way 'round sorta', of using VB as
the frontend for its GUI features is the real reason I ever got into VB
instead of Fortran entirely.

--


First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: Using Mapi Controls
Next: VarPtr() and StrPtr() questions