<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#cccccc">
    Thank you for your quick replies.  I'm impressed by the helpfulness
    and dedication of the D community!<br>
    Here's another one. Is there a way to pass arguments to functions by
    keyword as in the calls to f and g below?<br>
    <br>
    void f(int a = 0, int b = 1) {}<br>
    void g(int a) {}<br>
    <br>
    void main() { <br>
        f(b = 1, a = 0); // compile error<br>
        g(a = 0); // also compile error<br>
    }<br>
    <br>
    <br>
    <br>
    <br>
    <br>
    On 12/19/2011 03:00 PM, <a class="moz-txt-link-abbreviated" href="mailto:digitalmars-d-learn-request@puremagic.com">digitalmars-d-learn-request@puremagic.com</a>
    wrote:
    <blockquote
      cite="mid:mailman.9.1324324809.15842.digitalmars-d-learn@puremagic.com"
      type="cite">
      <pre wrap="">Send Digitalmars-d-learn mailing list submissions to
        <a class="moz-txt-link-abbreviated" href="mailto:digitalmars-d-learn@puremagic.com">digitalmars-d-learn@puremagic.com</a>

To subscribe or unsubscribe via the World Wide Web, visit
        <a class="moz-txt-link-freetext" href="http://lists.puremagic.com/cgi-bin/mailman/listinfo/digitalmars-d-learn">http://lists.puremagic.com/cgi-bin/mailman/listinfo/digitalmars-d-learn</a>

or, via email, send a message with subject or body 'help' to
        <a class="moz-txt-link-abbreviated" href="mailto:digitalmars-d-learn-request@puremagic.com">digitalmars-d-learn-request@puremagic.com</a>

You can reach the person managing the list at
        <a class="moz-txt-link-abbreviated" href="mailto:digitalmars-d-learn-owner@puremagic.com">digitalmars-d-learn-owner@puremagic.com</a>

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Digitalmars-d-learn digest..."


Today's Topics:

   1. Re: newbie question: Can D do this? (Ali ?ehreli)
   2. Re: newbie question: Can D do this? (Kai Meyer)
   3. Re: newbie question: Can D do this? (Simen Kj?r?s)
   4. Re: newbie question: Can D do this? (Ali ?ehreli)
   5. Re: newbie question: Can D do this? (Jonathan M Davis)


----------------------------------------------------------------------

Message: 1
Date: Mon, 19 Dec 2011 10:41:29 -0800
From: Ali ?ehreli <a class="moz-txt-link-rfc2396E" href="mailto:acehreli@yahoo.com"><acehreli@yahoo.com></a>
To: <a class="moz-txt-link-abbreviated" href="mailto:digitalmars-d-learn@puremagic.com">digitalmars-d-learn@puremagic.com</a>
Subject: Re: newbie question: Can D do this?
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:jco0gq$1ilt$1@digitalmars.com"><jco0gq$1ilt$1@digitalmars.com></a>
Content-Type: text/plain; charset=UTF-8; format=flowed

On 12/19/2011 08:17 AM, clk wrote:

 > 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.

We need more newbie topics here! :)

 > 1) Does D support something like the javascript 1.8 destructuring
 > assigment (multiple assigment in python):
 >
 > [a, b] = [b, a];

No multiple assignment like that. But useful approarches exist for most 
needs, like the swap that simendsjo has shown.

 > 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]

List comprehension is not part of the language.

import std.algorithm;

void f(int x)
{}

bool condition(int x)
{
     return true;
}

void main()
{
     auto list = [ 0, 1, 2 ];
     map!f(filter!condition(list));
}

You can define f and condition within the body of main().

It is possible to use function literals as well:

import std.algorithm;

void main()
{
     auto list = [ 0, 1, 2 ];
     map!((x){
             /* ... this is f(x) ...*/
         })(filter!((x) {
                     return true; /* ... condition ... */
                 })(list));
}

 > 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.

std.range.stride does that:

import std.range;
// ...
stride([1, 2, 3, 4, 5], 2)

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

Ali



------------------------------

Message: 2
Date: Mon, 19 Dec 2011 11:50:33 -0700
From: Kai Meyer <a class="moz-txt-link-rfc2396E" href="mailto:kai@unixlords.com"><kai@unixlords.com></a>
To: <a class="moz-txt-link-abbreviated" href="mailto:digitalmars-d-learn@puremagic.com">digitalmars-d-learn@puremagic.com</a>
Subject: Re: newbie question: Can D do this?
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:jco11q$1lle$1@digitalmars.com"><jco11q$1lle$1@digitalmars.com></a>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 12/19/2011 09:17 AM, clk wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">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];
</pre>
      </blockquote>
      <pre wrap="">
I would love multiple assignment like this, but it's tricky. But your 
usage isn't really multiple assignment as much as it is a swap. What I'd 
love is something like this:

[a, b, c] = [get_a(), get_b(), get_c()];

Or

[a, b, c] = [to!(int)(argv[1]), some_other_value, argv[4]);



</pre>
      <blockquote type="cite">
        <pre wrap="">
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]
</pre>
      </blockquote>
      <pre wrap="">
No, D's syntax is very C-ish. I don't expect syntax like this to ever 
show up (though what you are doing is possible with things like 
std.algorithm)

</pre>
      <blockquote type="cite">
        <pre wrap="">
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.
</pre>
      </blockquote>
      <pre wrap="">
Ya, std.range, like Ali said.

</pre>
      <blockquote type="cite">
        <pre wrap="">
I find the 3 features above extremely convenient in every day coding.
Thanks,
-clk

</pre>
      </blockquote>
      <pre wrap="">


------------------------------

Message: 3
Date: Mon, 19 Dec 2011 20:01:06 +0100
From: Simen Kj?r?s <a class="moz-txt-link-rfc2396E" href="mailto:simen.kjaras@gmail.com"><simen.kjaras@gmail.com></a>
To: <a class="moz-txt-link-abbreviated" href="mailto:digitalmars-d-learn@puremagic.com">digitalmars-d-learn@puremagic.com</a>
Subject: Re: newbie question: Can D do this?
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:op.v6q234mt0gpyof@biotronic.lan"><op.v6q234mt0gpyof@biotronic.lan></a>
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes

On Mon, 19 Dec 2011 17:17:43 +0100, clk <a class="moz-txt-link-rfc2396E" href="mailto:clk@clksoft.com"><clk@clksoft.com></a> wrote:

</pre>
      <blockquote type="cite">
        <pre wrap="">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];
</pre>
      </blockquote>
      <pre wrap="">

This, or something quite like it, was covered on Saturday in the thread
"Alias/Ref Tuples ?". This works (but is hardly as elegant as Python's
syntax:

import std.typetuple : TypeTuple;
import std.typecons : tuple;

TypeTuple!(a, b) = tuple(b,a);


------------------------------

Message: 4
Date: Mon, 19 Dec 2011 11:07:49 -0800
From: Ali ?ehreli <a class="moz-txt-link-rfc2396E" href="mailto:acehreli@yahoo.com"><acehreli@yahoo.com></a>
To: <a class="moz-txt-link-abbreviated" href="mailto:digitalmars-d-learn@puremagic.com">digitalmars-d-learn@puremagic.com</a>
Subject: Re: newbie question: Can D do this?
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:jco225$1r5m$1@digitalmars.com"><jco225$1r5m$1@digitalmars.com></a>
Content-Type: text/plain; charset=UTF-8; format=flowed

On 12/19/2011 10:39 AM, Jonathan M Davis wrote:
 > it's a range (see
 > <a class="moz-txt-link-freetext" href="http://www.informit.com/articles/printerfriendly.aspx?p=1407357">http://www.informit.com/articles/printerfriendly.aspx?p=1407357</a> for a 
general
 > explanation of the concept of ranges)

That's a great article.[1] I hope that this chapter is more 
beginner-friendly:

   <a class="moz-txt-link-freetext" href="http://ddili.org/ders/d.en/ranges.html">http://ddili.org/ders/d.en/ranges.html</a>

Ali

[1] Andrei's article has a Turkish translation as well:

   <a class="moz-txt-link-freetext" href="http://ddili.org/makale/eleman_erisimi_uzerine.html">http://ddili.org/makale/eleman_erisimi_uzerine.html</a>



------------------------------

Message: 5
Date: Mon, 19 Dec 2011 14:30:39 -0500
From: "Jonathan M Davis" <a class="moz-txt-link-rfc2396E" href="mailto:jmdavisProg@gmx.com"><jmdavisProg@gmx.com></a>
To: "digitalmars.D.learn" <a class="moz-txt-link-rfc2396E" href="mailto:digitalmars-d-learn@puremagic.com"><digitalmars-d-learn@puremagic.com></a>
Subject: Re: newbie question: Can D do this?
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:20111219193039.5420@gmx.com"><20111219193039.5420@gmx.com></a>
Content-Type: text/plain; charset="utf-8"

On Monday, December 19, 2011 11:07:49 Ali ?ehreli wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">That's a great article.[1] I hope that this chapter is more
beginner-friendly:

<a class="moz-txt-link-freetext" href="http://ddili.org/ders/d.en/ranges.html">http://ddili.org/ders/d.en/ranges.html</a>
</pre>
      </blockquote>
      <pre wrap="">
Cool. One of the things that we're missing on the website is a solid article 
on ranges (I started such an article a while back and really should go back 
and finish it), but having something like this to link to should be quite 
useful. I'll have to give it a read. Thanks!

- Jonathan M Davis


------------------------------

_______________________________________________
Digitalmars-d-learn mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Digitalmars-d-learn@puremagic.com">Digitalmars-d-learn@puremagic.com</a>
<a class="moz-txt-link-freetext" href="http://lists.puremagic.com/cgi-bin/mailman/listinfo/digitalmars-d-learn">http://lists.puremagic.com/cgi-bin/mailman/listinfo/digitalmars-d-learn</a>


End of Digitalmars-d-learn Digest, Vol 71, Issue 29
***************************************************

</pre>
    </blockquote>
    <br>
  </body>
</html>