digitalmars.D.learn - Flatten range of ranges
- new to d (4/4) May 06 2010 Is there any function in phobos that does something like that:
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (4/10) May 06 2010 How about chain:
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (3/14) May 06 2010 Sorry, of course that's not what you wanted... :(
- Philippe Sigaud (12/23) May 06 2010 I've this in a dsource project:
- Graham Fawcett (6/33) May 06 2010 These are great! Thank you. Coming from some of the languages that you
- Philippe Sigaud (5/8) May 06 2010 Fills, I'm not sure, but at least it's useful for me to digest both
- Graham Fawcett (6/28) May 06 2010 Newbie setup question: I'm interested in trying out dranges. What's the
- Graham Fawcett (10/38) May 06 2010 I should clarify that I know I can just put the dranges sources in, e.g,...
- Philippe Sigaud (19/28) May 06 2010 Then you know as much as me. I don't even compile them into a library, I
- new to d (2/48) May 06 2010 concat() in range2 seems to do exactly what i wanted, thank you. I thin...
Is there any function in phobos that does something like that: auto a = [[1,2],[3,4]]; assert(equals(flatten(a), [1,2,3,4])); I am just learning D and ca't find anything like that in the docs.
May 06 2010
new to d wrote:Is there any function in phobos that does something like that: auto a = [[1,2],[3,4]]; assert(equals(flatten(a), [1,2,3,4])); I am just learning D and ca't find anything like that in the docs.How about chain: http://digitalmars.com/d/2.0/phobos/std_range.html#chain Ali
May 06 2010
Ali Çehreli wrote:new to d wrote:Sorry, of course that's not what you wanted... :( AliIs there any function in phobos that does something like that: auto a = [[1,2],[3,4]]; assert(equals(flatten(a), [1,2,3,4])); I am just learning D and ca't find anything like that in the docs.How about chain: http://digitalmars.com/d/2.0/phobos/std_range.html#chain
May 06 2010
On Thu, May 6, 2010 at 18:24, Ali =C7ehreli <acehreli yahoo.com> wrote:Ali =C7ehreli wrote:I've this in a dsource project: http://svn.dsource.org/projects/dranges/trunk/docs/range2.html (look for flatten or concat). It's a lazy range. Flatten depends on a template for wrapping code, present in the traits2 module. http://www.dsource.org/projects/dranges/browser/trunk/range2.d http://www.dsource.org/projects/dranges/browser/trunk/traits2.d Hmm, this is waiting for quite an update. I've lots of thing for producing/mapping/filtering... ranges of ranges while conserving their topology/rank. If you find anything useful for you in this project, tell me! Philippenew to d wrote:Is there any function in phobos that does something like that: auto a =3D [[1,2],[3,4]]; assert(equals(flatten(a), [1,2,3,4])); I am just learning D and ca't find anything like that in the docs.
May 06 2010
On Thu, 06 May 2010 19:01:04 +0200, Philippe Sigaud wrote:On Thu, May 6, 2010 at 18:24, Ali Çehreli <acehreli yahoo.com> wrote:These are great! Thank you. Coming from some of the languages that you cite as inspirations, I found the limited set of range HOFs in D2 to be really unfortunate. Your project fills the gap! Best, GrahamAli Çehreli wrote:I've this in a dsource project: http://svn.dsource.org/projects/dranges/trunk/docs/range2.html (look for flatten or concat). It's a lazy range. Flatten depends on a template for wrapping code, present in the traits2 module. http://www.dsource.org/projects/dranges/browser/trunk/range2.d http://www.dsource.org/projects/dranges/browser/trunk/traits2.d Hmm, this is waiting for quite an update. I've lots of thing for producing/mapping/filtering... ranges of ranges while conserving their topology/rank. If you find anything useful for you in this project, tell me!new to d wrote:Is there any function in phobos that does something like that: auto a = [[1,2],[3,4]]; assert(equals(flatten(a), [1,2,3,4])); I am just learning D and ca't find anything like that in the docs.
May 06 2010
These are great! Thank you. Coming from some of the languages that you cite as inspirations, I found the limited set of range HOFs in D2 to be really unfortunate. Your project fills the gap!Fills, I'm not sure, but at least it's useful for me to digest both clojure/Haskell (got rid of Scala) and D :-) If you find any pb, don't hesitate to send me some mail, because I really discover these functions as I go forward... Philippe
May 06 2010
On Thu, 06 May 2010 19:01:04 +0200, Philippe Sigaud wrote:On Thu, May 6, 2010 at 18:24, Ali Çehreli <acehreli yahoo.com> wrote:Newbie setup question: I'm interested in trying out dranges. What's the best way for me to "install" dranges, so that my test code can reference range2 and the other drange modules? Thanks, GrahamAli Çehreli wrote:I've this in a dsource project: http://svn.dsource.org/projects/dranges/trunk/docs/range2.html (look for flatten or concat). It's a lazy range. Flatten depends on a template for wrapping code, present in the traits2 module. http://www.dsource.org/projects/dranges/browser/trunk/range2.d http://www.dsource.org/projects/dranges/browser/trunk/traits2.dnew to d wrote:Is there any function in phobos that does something like that: auto a = [[1,2],[3,4]]; assert(equals(flatten(a), [1,2,3,4])); I am just learning D and ca't find anything like that in the docs.
May 06 2010
On Thu, 06 May 2010 17:25:44 +0000, Graham Fawcett wrote:On Thu, 06 May 2010 19:01:04 +0200, Philippe Sigaud wrote:I should clarify that I know I can just put the dranges sources in, e.g, a 'dranges' subdirectory, compile drange/*.d into a library and do something like: dmd -Ldranges/dranges.a -Idranges test.d ...and I could modify /etc/dmd.conf by hand to add my dranges directory to the appropriate paths. But I wonder if I'm missing a more idiomatic way to install third-party libraries for D2. Thanks, GrahamOn Thu, May 6, 2010 at 18:24, Ali Çehreli <acehreli yahoo.com> wrote:Newbie setup question: I'm interested in trying out dranges. What's the best way for me to "install" dranges, so that my test code can reference range2 and the other drange modules?Ali Çehreli wrote:I've this in a dsource project: http://svn.dsource.org/projects/dranges/trunk/docs/range2.html (look for flatten or concat). It's a lazy range. Flatten depends on a template for wrapping code, present in the traits2 module. http://www.dsource.org/projects/dranges/browser/trunk/range2.d http://www.dsource.org/projects/dranges/browser/trunk/traits2.dnew to d wrote:Is there any function in phobos that does something like that: auto a = [[1,2],[3,4]]; assert(equals(flatten(a), [1,2,3,4])); I am just learning D and ca't find anything like that in the docs.
May 06 2010
Graham:I should clarify that I know I can just put the dranges sources in, e.g,a 'dranges' subdirectory, compile drange/*.d into a library and do something like: dmd -Ldranges/dranges.a -Idranges test.d ...and I could modify /etc/dmd.conf by hand to add my dranges directory to the appropriate paths. But I wonder if I'm missing a more idiomatic way to install third-party libraries for D2. Thanks, GrahamThen you know as much as me. I don't even compile them into a library, I just add them into my current project (Code::Blocks accepts this) and compile the entire project. I just put a zip file in the download area with some new modules and all the modules inside a dranges directory. What I'd do is just putting the dranges dir inside my project and do import dranges.all; in my own module. It seems in this case you don't even need to indicate any path or whatever. " module mymod; import dranges.all; void main() {} " % dmd mymod (untested, I use DMD under windows and am on Linux right now, but IIRC it worked for me.) Philippe
May 06 2010
Philippe Sigaud Wrote:On Thu, May 6, 2010 at 18:24, Ali Çehreli <acehreli yahoo.com> wrote:concat() in range2 seems to do exactly what i wanted, thank you. I think something like that should be included in the standard library since it's a pretty basic operation. I haven't taken a good look at the other stuff in range2 yet.Ali Çehreli wrote:I've this in a dsource project: http://svn.dsource.org/projects/dranges/trunk/docs/range2.html (look for flatten or concat). It's a lazy range. Flatten depends on a template for wrapping code, present in the traits2 module. http://www.dsource.org/projects/dranges/browser/trunk/range2.d http://www.dsource.org/projects/dranges/browser/trunk/traits2.d Hmm, this is waiting for quite an update. I've lots of thing for producing/mapping/filtering... ranges of ranges while conserving their topology/rank. If you find anything useful for you in this project, tell me! Philippe <br><br><div class="gmail_quote">On Thu, May 6, 2010 at 18:24, Ali Çehreli <span dir="ltr"><<a href="mailto:acehreli yahoo.com">acehreli yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"> <div><div></div><div class="h5">Ali Çehreli wrote:<br> <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"> new to d wrote:<br> <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"> Is there any function in phobos that does something like that:<br> <br> auto a = [[1,2],[3,4]];<br> assert(equals(flatten(a), [1,2,3,4]));<br> <br> I am just learning D and ca't find anything like that in the docs.<br></blockquote></blockquote></div></div></blockquote><div><br>I've this in a dsource project:<br><br><a href="http://svn.dsource.org/projects/dranges/trunk/docs/range2.html">http://svn.dsource.org/projects/dranges/trunk/ ocs/range2.html</a> <br> </div></div>(look for flatten or concat). It's a lazy range. Flatten depends on a template for wrapping code, present in the traits2 module.<br><br><a href="http://www.dsource.org/projects/dranges/browser/trunk/range2.d">http://www.dsource.org/projects/dranges/browser/trunk/range2.d</a><br> <a href="http://www.dsource.org/projects/dranges/browser/trunk/traits2.d">http://www.dsource.org/projects/dranges/browser/trunk/trait 2.d</a><br><br>Hmm, this is waiting for quite an update. I've lots of thing for producing/mapping/filtering... ranges of ranges while conserving their topology/rank.<br> If you find anything useful for you in this project, tell me!<br><br><br>Philippe<br><br>new to d wrote:Is there any function in phobos that does something like that: auto a = [[1,2],[3,4]]; assert(equals(flatten(a), [1,2,3,4])); I am just learning D and ca't find anything like that in the docs.
May 06 2010