Functional programming

Rustom Mody rustompmody at gmail.com
Mon Mar 3 09:08:11 EST 2014


On Monday, March 3, 2014 7:30:17 PM UTC+5:30, Chris Angelico wrote:
> On Tue, Mar 4, 2014 at 12:48 AM, Rustom Mody wrote:
> > ? [1,2] + [[3,4],[5]]
> > ERROR: Type error in application
> > *** expression     : [1,2] + [[3,4],[5]]
> > *** term           : [1,2]
> > *** type           : [Int]
> > *** does not match : [[Int]]
> > IOW [1,2,[3,4],[5]]
> > is a type-wise ill-formed expression just as in python
> > [[1,2])
> > is syntax-wise ill-formed
> > Is it worth having such a restriction?
> > Thats a different argument...

> How do you know that [1,2] is a list that must contain nothing but
> integers? By extension, it's also a list that must contain positive
> integers less than three, so adding [5] violates that. And [] is a
> list that must contain nothing, ergo it can't be added to, although
> (since it contains nothing) it can be added to anything.

If 'integer-less-than-3' were a type then yes there would be this
problem. More generally, if types could overlap then automatic
type-inference is impossible

Whether all thats good is as I earlier said a different argument

The OP asked about FP and so its appropriate to mention how python's
and standard FPL's choices differ



More information about the Python-list mailing list