* nice features in Ada 2012, expressions
@ 2012-06-20 9:29 Nasser M. Abbasi
2012-06-20 9:38 ` Pascal Obry
0 siblings, 1 reply; 2+ messages in thread
From: Nasser M. Abbasi @ 2012-06-20 9:29 UTC (permalink / raw)
I was looking at Ada 2012 expressions
http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf
and I really like what I see. Ada is becoming more expressive now,
with less code, which I think is a good thing(TM).
It is getting almost as short as Matlab now (but with the strong
type build-in)
Given a matrix A, and I want to find if all elements in
the matrix are say positive, then in Matlab I would write
--------------------
B = all(A(:)>0)
In ada 2012 it is
B := (for all e of A => e>0);
--------------------
and if I want to find if there is at least one
value > 0 then in Matlab I would write
----------------------
B = any(A(:)>0)
and in Ada 2012
B := (for some e of A => e>0);
-----------------------
I think this is nice.
I am not sure yet, since I do not know much about Ada 2012,
if I can use this new iterator form if A was a standard array
variable, or if it will work only if A was a 'container' variable?
i.e. if A above was just variable of type like
'A_type is array(integer) of float'
I hope it will work on standard arrays and not just on
collections so I can use it this form more.
I think these are the type of improvements needed in Ada to
make it more popular and more used. Real practical and
useful things.
I am looking forward for the 2012 gnat to try it out.
--Nasser
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: nice features in Ada 2012, expressions
2012-06-20 9:29 nice features in Ada 2012, expressions Nasser M. Abbasi
@ 2012-06-20 9:38 ` Pascal Obry
0 siblings, 0 replies; 2+ messages in thread
From: Pascal Obry @ 2012-06-20 9:38 UTC (permalink / raw)
Nasser,
> I am not sure yet, since I do not know much about Ada 2012,
> if I can use this new iterator form if A was a standard array
> variable, or if it will work only if A was a 'container' variable?
It works fine with standard arrays.
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net - http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-20 9:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-20 9:29 nice features in Ada 2012, expressions Nasser M. Abbasi
2012-06-20 9:38 ` Pascal Obry
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox