More Phobos testing

spir denis.spir at gmail.com
Wed Jan 26 09:51:28 PST 2011


On 01/26/2011 01:56 PM, bearophile wrote:
> Now and then I try to use the std.algorithm/std.range parts of Phobos2 to see how they are going and developing.
>
> Here I have found Python3 code to compute the Pascal triangle:
> [...]
> Some notes on the D2 version:
>
> 1) In Python I am used to think of higher order functions like map, filter, and zip as similar things. But in Phobos zip is in std.range while map is in std.algorithm. I think this different placement is bad.

Why? zip is imo clearly a "sequential" function; belongs where it is.
An alternative may be to have a more type-oriented organisation of Phobos: 
then, all algorithms oerating on ranges (many) would be placed in std.range.

> 4) In the Python2 version if I print using the pretty print module:
>
> from pprint import pprint
> pprint(pascal_triangle(5), width=20)
>
> The triangle gets visualized like this:
>
> [[1],
>   [1, 1],
>   [1, 2, 1],
>   [1, 3, 3, 1],
>   [1, 4, 6, 4, 1]]
>
> A function like pprint() will be useful in std.string of Phobos2 too, to give a more readable printing. It's useful to print 2D arrays, arrays of dicts, etc, in a more readable way.

Agreed. I very often write and use tree-like output.
As an alternative, I would even like a recursive treeView func/method on all 
aggregate types (arrays, AAs, strucs & classes). Producing eg:

aPoint:
     tag: "foo"
     color:
         r: 11
         g: 22
         b: 33
     position:
         x: 1
         y: 2
with optional separators ',' & delimitors () [] {}.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d mailing list