newbie question: Can D do this?

clk clk at clksoft.com
Mon Dec 19 08:17:43 PST 2011


Hello,
I'm new to this mailing list.  I'm trying to learn D  to eventually use 
it in production code.
I'm a little bit intimidated by the fact that the topics in the d-learn 
list look rather advanced to a newbie like me.
I have 3 fairly simple questions:

1) Does D support something like the javascript 1.8 destructuring 
assigment (multiple assigment in python):

[a, b] = [b, a];

2) D doesn't  seem to support the list comprehension syntax available in 
python and javascript.  Is this correct?

[f(x) for x in list if condition]

3) D's slice operator apparently doesn't allow the use of a stride other 
than unity as is allowed with fortran and matlab.  Is there a way to 
implement this feature so that

[1, 2, 3, 4, 5][0..$:2] would refer to [1, 3, 5], etc..., where 2 is the 
non unit stride.  Or is the find function from std.algorithm the only 
option to achieve the same behavior.

I find the 3 features above extremely convenient in every day coding.
Thanks,
-clk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20111219/bfef332c/attachment.html>


More information about the Digitalmars-d-learn mailing list