Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.haskell > #404
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.haskell |
| Subject | Re: how to compute one and filter it immediately rather than calculated all and then filter the whole |
| Date | 2016-07-22 09:40 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87zipa9ic1.fsf@bsb.me.uk> (permalink) |
| References | <3f8a8fce-1bce-4ae3-b8aa-8d0a663c2c94@googlegroups.com> <87lh0vatz3.fsf@bsb.me.uk> <7ddd00e7-5166-4bf9-a08e-abd075c148b8@googlegroups.com> <1ed5d847-90ff-4cdb-8488-b8179fb94fc3@googlegroups.com> <045b96eb-79bf-4079-b17b-8c39016c7398@googlegroups.com> |
meInvent bbird <jobmattcon@gmail.com> writes: > [g x | x <- [1..20], f x] > > i do not understand why i do not specify to filter true in f x > and it can get the true? > > how do it know i must choose true? Just because that's what the syntax means. After the | you write generators (like x <- [1..2]) or Boolean guards that refine what generated values are permitted. For example [i | i <- [1..20], True] is just [1..20] and [i | i <- [1..20], False] is just []. Note that writing the filtered list like this may be slower than the original version you had. It all depends on how the calculation of the pairs is done. Your example is rather complicated and that's putting me off looking at the details. <snip> -- Ben.
Back to comp.lang.haskell | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to compute one and filter it immediately rather than calculated all and then filter the whole meInvent bbird <jobmattcon@gmail.com> - 2016-07-21 05:07 -0700
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-07-21 16:31 +0100
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole meInvent bbird <jobmattcon@gmail.com> - 2016-07-21 19:29 -0700
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole meInvent bbird <jobmattcon@gmail.com> - 2016-07-21 19:47 -0700
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole meInvent bbird <jobmattcon@gmail.com> - 2016-07-21 21:38 -0700
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-07-22 09:40 +0100
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole meInvent bbird <jobmattcon@gmail.com> - 2016-07-22 01:57 -0700
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole meInvent bbird <jobmattcon@gmail.com> - 2016-07-22 02:02 -0700
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole meInvent bbird <jobmattcon@gmail.com> - 2016-07-22 02:04 -0700
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole meInvent bbird <jobmattcon@gmail.com> - 2016-07-22 04:33 -0700
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole meInvent bbird <jobmattcon@gmail.com> - 2016-07-23 02:36 -0700
Re: how to compute one and filter it immediately rather than calculated all and then filter the whole meInvent bbird <jobmattcon@gmail.com> - 2016-07-25 00:55 -0700
csiph-web