On 13/12/2012, at 12:24 AM, srean wrote:

> oh no problem, just mentioned in case you hadnt noticed.

I generally don't notice because I use my local machine.
Especially now I have figured out Mac OSX launch daemon,
so the Felix webserver is always running as soon as I login.

Anyhow its up now.
I'm adding some more examples.

BTW: re slices.

In mathematics given a function:

        f: A -> B

then given a subset A0 of A, it is common to call

        B0 = f (A0)

defined by:

        { b in B | exists a in A0 such that b = f (a) }

the *image* of A0 in B. 

In plain English: all the elements
of B that the elements of A0 map to :)

This is a purely functional notion unlike your assignment
example, but lets ignore that for now and just consider
the functional aspect.

Clearly, since an array  like int ^ 20 is just a mapping

        20 -> int

then for any subset of 20 (such as all the even values)
we have a notion of image. Of course this applies to a slice
as well since thats a subset.

The "problem" here is two fold. The first is "what do we
mean by a set". Any array or list can be considered a set.
In fact there is a type class for Set, but its an abstraction
(a set is anything with a membership function).

Unfortunately the definition of "image" given above
is not constructive. A constructive specification
is not allowed to say "there exists": plain existential
quantifiers are banned.

Instead, you have to actually *calculate* the value.

To do this, we have to build a concrete image
of the input set (slice, or whatever). That means
the input image must be iterable, and the output
image has to be a *particular* data structure into
which we store the results.

the "natural" way to do this is to mirror the input set.
For example

        f ( (list (1,2,3,4) ) => list ( f 1, f 2, f 3, f 4) )

        f ( (1,2,3,4) ) => f 1, f 2, f3, f 4

This is hard to do! Because you have to find a constructor
of an empty object and a way to add to it, from the type
of the argument to f, eg "list" or "array". They're 
data functors not types.

However we already have this function. Its just "map".

        map f (1,2,3,4)
        map f ( list (1,2,3,4) )

So really for slices, all we need to do is decide what

        first:last:stride

or whatever is: if its just a notation for an array 
of indices for example, then the map will produce
an array of values.

We could easily define a cute syntax for map like:

        f [< ... >]

Note that without this, there's a huge risk of ambiguity:

        f (1,2)

might call f : int * int -> int, instead of map f (1,2).



--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to