Welcome to Web-News
A Web-based News Reader
Subject Re: Treating the abusive unsigned syndrome
From Kagamin <spam@here.lot>
Date Wed, 26 Nov 2008 10:36:01 -0500
Newsgroups digitalmars.D

bearophile Wrote:

> From the len() code I have posted you can see there are other places where you want to use len(), in particular to count the number of items that a lazy generator (opApply for now) yields.
>
hmm...

import std.stdio, std.algorithm;

void main()
{
        bool pred(int x){ return x>2; }
        auto counter=(int count, int x){ return pred(x)?count+1:count; };
        int[] a=[0,1,2,3,4];
        auto lazylen=reduce!(counter)(0,a);
        writeln(lazylen); //2
}

Recent messages in this thread
 
-# Treating the abusive unsigned syndrome Andrei Alexandrescu 25-Nov-2008 10:59 am
.-# Re: Treating the abusive unsigned syndrome Denis Koroskin 25-Nov-2008 11:13 am
.|\# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 25-Nov-2008 11:19 am
.-# Re: Treating the abusive unsigned syndrome bearophile 25-Nov-2008 11:38 am
.|-# Re: Treating the abusive unsigned syndrome bearophile 25-Nov-2008 11:47 am
.||-# Re: Treating the abusive unsigned syndrome Steven Schveighoffer 25-Nov-2008 12:06 pm
.||.-# Re: Treating the abusive unsigned syndrome bearophile 25-Nov-2008 12:22 pm
.||..-# Re: Treating the abusive unsigned syndrome Nick Sabalausky 25-Nov-2008 06:18 pm
.||...-# Re: Treating the abusive unsigned syndrome KennyTM~ 26-Nov-2008 01:21 am
.||....-# Re: Treating the abusive unsigned syndrome Nick Sabalausky 26-Nov-2008 08:17 am
.||.....-# Re: Treating the abusive unsigned syndrome bearophile 26-Nov-2008 08:24 am
.||......-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 26-Nov-2008 09:58 am
.||......|-# Re: Treating the abusive unsigned syndrome bearophile 26-Nov-2008 11:29 am
.||......||\# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 26-Nov-2008 11:40 am
.||......|\# Re: Treating the abusive unsigned syndrome Christopher Wright 26-Nov-2008 06:31 pm
.||......\# Re: Treating the abusive unsigned syndrome (Current message) Kagamin 26-Nov-2008 10:36 am
.|\# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 25-Nov-2008 11:55 am
.-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 25-Nov-2008 12:06 pm
.|-# Re: Treating the abusive unsigned syndrome Steven Schveighoffer 25-Nov-2008 12:27 pm
.||\# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 25-Nov-2008 01:24 pm
.|-# Re: Treating the abusive unsigned syndrome Sergey Gromov 25-Nov-2008 03:48 pm
.|.-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 25-Nov-2008 04:49 pm
.|..-# Re: Treating the abusive unsigned syndrome Sergey Gromov 25-Nov-2008 05:01 pm
.|...\# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 25-Nov-2008 05:17 pm
.-# Re: Treating the abusive unsigned syndrome Russell Lewis 25-Nov-2008 09:26 am
.|-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 25-Nov-2008 04:39 pm
.|.-# Re: Treating the abusive unsigned syndrome bearophile 25-Nov-2008 04:56 pm
.|.|-# Re: Treating the abusive unsigned syndrome Nick Sabalausky 25-Nov-2008 06:05 pm
.|.||\# Re: Treating the abusive unsigned syndrome Kagamin 26-Nov-2008 08:02 am
.|.||# Re: Treating the abusive unsigned syndrome Daniel de Kok 25-Nov-2008 06:05 pm
.|.|\# Re: Treating the abusive unsigned syndrome Ary Borenszweig 26-Nov-2008 02:04 pm
.|.-# Re: Treating the abusive unsigned syndrome Sean Kelly 25-Nov-2008 05:06 pm
.|.|\# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 25-Nov-2008 10:55 pm
.|.-# Re: Treating the abusive unsigned syndrome Michel Fortin 26-Nov-2008 10:16 am
.|..-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 26-Nov-2008 10:24 am
.|...-# Re: Treating the abusive unsigned syndrome Michel Fortin 26-Nov-2008 11:08 am
.|...|-# Re: Treating the abusive unsigned syndrome Don 26-Nov-2008 12:49 pm
.|...|.-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 26-Nov-2008 01:30 pm
.|...|..\# Re: Treating the abusive unsigned syndrome Michel Fortin 26-Nov-2008 03:18 pm
.|...-# Re: Treating the abusive unsigned syndrome Denis Koroskin 26-Nov-2008 12:50 pm
.|....-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 26-Nov-2008 01:45 pm
.|.....|# Re: Treating the abusive unsigned syndrome Denis Koroskin 26-Nov-2008 02:53 pm
.|.....-# Re: Treating the abusive unsigned syndrome Don 27-Nov-2008 04:19 am
.|......-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 27-Nov-2008 09:27 am
.|.......-# Re: Treating the abusive unsigned syndrome Don 27-Nov-2008 11:23 am
.|........-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 27-Nov-2008 11:49 am
.|.........-# Re: Treating the abusive unsigned syndrome KennyTM~ 27-Nov-2008 04:24 pm
.|..........-# Re: Treating the abusive unsigned syndrome KennyTM~ 27-Nov-2008 04:31 pm
.|...........-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 27-Nov-2008 05:14 pm
.|............-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 27-Nov-2008 10:34 pm
.|............|\# Re: Treating the abusive unsigned syndrome Michel Fortin 28-Nov-2008 07:43 am
.|............-# Re: Treating the abusive unsigned syndrome Don 28-Nov-2008 07:42 am
.|.............-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 28-Nov-2008 09:22 am
.|.............|-# Re: Treating the abusive unsigned syndrome Don 28-Nov-2008 11:09 am
.|.............|.-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 28-Nov-2008 11:29 am
.|.............|.|\# Re: Treating the abusive unsigned syndrome Don 28-Nov-2008 11:44 am
.|.............|.-# Re: Treating the abusive unsigned syndrome Derek Parnell 28-Nov-2008 03:55 pm
.|.............|..\# Re: Treating the abusive unsigned syndrome Frits van Bommel 28-Nov-2008 07:17 pm
.|.............\# Re: Treating the abusive unsigned syndrome Sean Kelly 28-Nov-2008 12:58 pm
.|# Re: Treating the abusive unsigned syndrome Sean Kelly 25-Nov-2008 04:57 pm
.-# Re: Treating the abusive unsigned syndrome Don 26-Nov-2008 04:18 am
.|-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 26-Nov-2008 10:12 am
.||-# Re: Treating the abusive unsigned syndrome Sean Kelly 26-Nov-2008 02:17 pm
.|||-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 26-Nov-2008 04:44 pm
.|||.-# Re: Treating the abusive unsigned syndrome Lars Kyllingstad 26-Nov-2008 05:40 pm
.|||.|\# Re: Treating the abusive unsigned syndrome Lars Kyllingstad 26-Nov-2008 06:06 pm
.|||.-# Re: Treating the abusive unsigned syndrome Kagamin 27-Nov-2008 10:15 am
.|||..\# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 27-Nov-2008 10:22 am
.||-# Re: Treating the abusive unsigned syndrome Sergey Gromov 26-Nov-2008 03:16 pm
.||.-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 26-Nov-2008 04:57 pm
.||.||# Re: Treating the abusive unsigned syndrome Sergey Gromov 26-Nov-2008 06:18 pm
.||.|-# Re: Treating the abusive unsigned syndrome bearophile 26-Nov-2008 07:09 pm
.||.|.-# Re: Treating the abusive unsigned syndrome Kagamin 27-Nov-2008 10:37 am
.||.|..\# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 27-Nov-2008 10:52 am
.||.\# Re: Treating the abusive unsigned syndrome Walter Bright 26-Nov-2008 05:14 pm
.|-# Re: Treating the abusive unsigned syndrome Sean Kelly 26-Nov-2008 02:10 pm
.|.-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 26-Nov-2008 05:03 pm
.|..-# Re: Treating the abusive unsigned syndrome Sean Kelly 26-Nov-2008 07:46 pm
.|...-# Re: Treating the abusive unsigned syndrome Denis Koroskin 26-Nov-2008 09:20 pm
.|....\# Re: Treating the abusive unsigned syndrome Sean Kelly 27-Nov-2008 12:15 pm
.-# Re: Treating the abusive unsigned syndrome Michel Fortin 26-Nov-2008 10:24 am
.||# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 26-Nov-2008 10:28 am
.|\# Re: Treating the abusive unsigned syndrome Nick Sabalausky 26-Nov-2008 03:44 pm
.-# Re: Treating the abusive unsigned syndrome Tomas Lindquist O... 26-Nov-2008 07:44 pm
.|\# Re: Treating the abusive unsigned syndrome Christopher Wright 26-Nov-2008 10:25 pm
.|# Re: Treating the abusive unsigned syndrome Simen Kjaeraas 26-Nov-2008 08:48 pm
.-# Re: Treating the abusive unsigned syndrome Derek Parnell 27-Nov-2008 05:14 pm
..-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 27-Nov-2008 05:23 pm
...-# Re: Treating the abusive unsigned syndrome Derek Parnell 27-Nov-2008 05:55 pm
....-# Re: Treating the abusive unsigned syndrome Andrei Alexandrescu 27-Nov-2008 10:19 pm
.....\# Re: Treating the abusive unsigned syndrome bearophile 28-Nov-2008 03:35 am