(sequence (comp (map inc) (filter even?)) (range 10))
;;=> (2 4 6 8 10)
(->> (range 10) (map inc) (filter even?))
;;=> (2 4 6 8 10)
Both test functions in transduce-bench return 250000500000.93 karma · joined September 23, 2009
My thoughts: http://pyrtsa.posterous.com
My tweets: http://twitter.com/pyrtsa
I write software for http://futurice.com in Helsinki, Finland, and study Engineering Physics and Computational Science at http://aalto.fi.
(sequence (comp (map inc) (filter even?)) (range 10))
;;=> (2 4 6 8 10)
(->> (range 10) (map inc) (filter even?))
;;=> (2 4 6 8 10)
Both test functions in transduce-bench return 250000500000.C++ makes it possible for the library writer to take care of freeing the resources automatically.
if (x < 100) throw new Exception("Weird!); // LEAK!
You shouldn't use `new` either when throwing exceptions. Just: if (x < 100) throw Exception("Weird!); // no leak.- partial construction: having to deal with already allocated pointers in case of errors during the construction - copy construction: who owns the resources? (Alternatively, you'll need to remember to disable the copy constructor explicitly.) - copy assignment: likewise
Doing the Right Thing is just so much easier when you wrap those member objects into e.g. `std::unique_ptr<T>`. That'll disable copy construction and assignment, which means that you'll need to think of that separately if it's needed.
Here's how you can say the same in a more positive manner:
> This is neat, and it would be even better if there was feedback when…
To keep up the hacker spirit, I find it amusing that the words "but" and "and" are logically equivalent (i.e. they both are representations of the logical ∧ operator), just with different connotations. :)
(Edit: It's actually a social hack to say your negatively toned "but" phrase with a positive "and" instead.)
Promise libraries, like RSVP.js [1] he referred to, typically implement a way to construct a promise with a depends-on-many relationship, as a function possibly called `all([p1, p2, ...])` (with the same type signature as for `list`), `and(p1, p2, ...)` or something similar.
IMO, defining the `list` function that way would've been clearer to the reader and more FP'ish, treating the `promises` argument in as a value and not a mutable object.
[1]: https://github.com/tildeio/rsvp.js/blob/master/lib/rsvp/all....
template <size_t N>
typename enable_if<(1 < N && N < 10), void>::type
foo(int (&bar)[N])
{
// called when 1 < N && N < 10
}
template <size_t N>
typename enable_if<(N >= 10), void>::type
foo(int (&bar)[N])
{
// called when N >= 10
}
OTOH, the key advantage in static_assert is the meaningful error message. template <size_t N>
typename enable_if<(N >= 10), void>::type
foo(int (&bar)[N]) { ... }
EDIT: Changed condition from N >= 0 into a more meaningful one. X-) (-> (california) bay-in city-on) ; "The Californian bay's city"
vs. (city-on (bay-in (california))) ; "The city on the bay in California"
The former ("->") starts with what's fed into the pipeline, the latter starts with what you get out of it. In addition, "->" avoids the nesting of expressions regardless of the number of steps, which might be useful in some cases. But both styles have their place.Good to hear that you got it resolved, but are you sure that your character encoding settings are alright?
I'm still thinking whether to switch my blog to another platform, maybe even an own server, as that's not the only problem I've had trying to embed source code examples to my posts.
Much of it boils down to the use of the Tiny MCE editor, that I'm a bit surprised Posterous is enforcing everybody to use!
template <typename A, typename B>
struct between_ {
A a; B b;
between_(A const & a, B const & b) : a(a), b(b) {}
template <typename T>
bool operator()(T const & t) const { return a < t && t < b; }
};
template <typename A, typename B>
between_<A, B> between(A const & a, B const & b) {
return between_<A, B>(a, b);
}
// ...
auto i = find_if(begin(v), end(v), between(x, y));
Verbose? Admittedly. Except maybe for the point of use, i.e. the last line. Which, I think, helps a lot anyway.But if you really need a compact notation for smart pointers, you'll get pretty close by using template aliases, e.g.
template <typename T> using up = std::unique_ptr<T>;
template <typename T> using sp = std::shared_ptr<T>;
// ...
up<int> foo(sp<int> bar) {
return bar ? up<int>(new int(*bar)) : nullptr;
} 19+18+18+18+19 (iPhone 3GS)
38+36+36+36+38 (iPhone 4)Combining a good UI to the propagators as explained by Sussman in this video, would make a disruptive product on any field where decision making is needed. (Not like such tools didn't exist already in the hands of some, of course.)
[edit] fix typo
[1]: http://timekiwi.com/timeline.html#posterous=garry.posterous....
Edit: Ok, it might not feel that natural anymore with the scrolling behavior, since the timeline itself has time pointing upwards. How about moving the menu to the top?
And where conditionals are costly, you can use tricks like:
float temp = min(x, y);
x = max(x, y);
y = temp;
instead of the conditional swapping operations, to make the whole network sorting algorithm deterministic. (Edit: notice that min() and max() here are hardware operations.)But it was a fun story, though.
http://visualnary.com/2008/04/13/lens-that-takes-multiple-pi... http://visualnary.com/2008/04/13/nab-predictions.html
Considering that, we'd need to state Euler's identity as: e^(i * pi/2) = i, but again we'd know nothing about fractions of that exponent. And there we go!
The point is, Euler's identity is a nice property of the definition of complex numbers, but in itself, not too generic. That's why OP's form, e^(i*tau) = 1, would do just fine.
Edit: fixed asterisks.