Re: [julia-users] functions on iterable types

2015-10-26 Thread DNF
Hmm. Trying to answer myself: I guess my suggested solution would miss functions that don't specify the type, but just rely on the iterable behaviour. On Monday, October 26, 2015 at 6:53:03 AM UTC+1, DNF wrote: > > I may be missing something, but what about using the TypeTrees module to >

Re: [julia-users] functions on iterable types

2015-10-26 Thread DNF
I must admit I don't understand very well what snippet is supposed to do. But, for example, it doesn't work for :sum or :maximum or anything like that. On Monday, October 26, 2015 at 9:23:35 AM UTC+1, harven wrote: > > > > Le lundi 26 octobre 2015 07:15:56 UTC+1, DNF a écrit : >> >> Hmm. Trying

Re: [julia-users] functions on iterable types

2015-10-26 Thread harven
Le lundi 26 octobre 2015 07:15:56 UTC+1, DNF a écrit : > > Hmm. Trying to answer myself: I guess my suggested solution would miss > functions that don't specify the type, but just rely on the iterable > behaviour. > > It is easy to get the list of thunks that work on iterables. type

Re: [julia-users] functions on iterable types

2015-10-26 Thread harven
Le lundi 26 octobre 2015 12:52:04 UTC+1, DNF a écrit : > > I must admit I don't understand very well what snippet is supposed to do. > But, for example, it doesn't work for :sum or :maximum or anything like > that. > > A thunk is a function that takes a single argument. Cheers,

Re: [julia-users] functions on iterable types

2015-10-26 Thread Stefan Karpinski
On Mon, Oct 26, 2015 at 9:28 AM, harven wrote: > > A thunk is a function that takes a single argument. > A thunk is a zero-argument function in functional programming – i.e. a piece of deferred computation.

Re: [julia-users] functions on iterable types

2015-10-25 Thread harven
Thanks for your answer. Still, there could be an Iterable abstract type and then functions could dispatch on it. Actually there are 34 functions in Base with an argument called `itr`. These are good candidates to dispatch on such a type. A bit like the Enumerate type. Nothing fancy, just a

Re: [julia-users] functions on iterable types

2015-10-25 Thread harven
> > I can see that there are some functions listed under the Iteration > section > > but it does not seem to be the full story. > > For example mapreduce works on iterable types (nice) but it seems that > the > > length function is not defined on iterables. Why is it so? > > Iterables can

Re: [julia-users] functions on iterable types

2015-10-25 Thread Steven G. Johnson
It's not practical for Iterable to be an abstract type because Julia doesn't have multiple inheritance.

Re: [julia-users] functions on iterable types

2015-10-25 Thread DNF
I may be missing something, but what about using the TypeTrees module to obtain the typenames, and then using methodswith() to establish whether each type has the methods start, next and stop? It would be a bit slow, of course, but if you dig around in the source code of methodswith you could

[julia-users] functions on iterable types

2015-10-25 Thread harven
An iterable type is obtained by defining start, next and end methods for such a type. Is there a way to obtain the list of all functions that work on iterable types? I can see that there are some functions listed under the Iteration section but it does not seem to be the full story. For

Re: [julia-users] functions on iterable types

2015-10-25 Thread Mauro
> An iterable type is obtained by defining start, next and end methods for > such a type. > Is there a way to obtain the list of all functions that work on iterable > types? No, that is not possible at the moment. Interfaces/traits are implicit in Julia (for now) and it is not (easily) possible