Using Brandon's code as a starting point (as it's far neater than
mine), let's try asking some questions about fractions (I've included
the whole program at the end).
questions = [ addition 1 2, addition (1%2) (1%3) ]
This works, but the the fractions are shown as 1 % 2 and to make it
On 2010 Oct 15, at 13:32, Jacek Generowicz wrote:
questions = [ addition 1 2, addition (1%2) (1%3) ]
My problem is that I don't see where I could add a type signature,
but still keep
addition :: a - a - Question
polymorphic.
Well, OK, I could write
addition 1 (2 :: Int)
How
are you expecting to call the functions in that container? for f in
c: try: return f(*misc_args) except: pass?
to_do = [(call, (AuntMabel,)),
(buy, ([(12*kg, sugar), (6*bushel, wheat)])),
(introduce, (Romeo, Juliet))]
for do,it in to_do:
do(*it)
As has been
On 2010 Oct 14, at 05:27, Brandon Moore wrote:
If you just want instances of questions you can keep it simple. How
about something isomorphic to
data Instance = Instance { question : String, answer : String,
check : String - Bool }
At first blush, I hated all those Strings hiding the
On 2010 Oct 14, at 05:39, Brandon Moore wrote:
On Oct 13, 2010, at 7:44 PM, Jacek Generowicz jacek.generow...@cern.ch
wrote:
On 2010 Oct 14, at 01:32, Evan Laforge wrote:
I think I'm starting too see what my problem is. I think it boils
down to
hankering for Duck Typing and variadic
Hi,
Am Donnerstag, den 14.10.2010, 09:34 +0200 schrieb Jacek Generowicz:
Another example:
Let's say I need an Int - String. Both
(fnA2 :: Banana - String) . (fnA1:: Int - Banana)
and
(fnB2 :: Onion - String) . (fnB1 :: Int - Onion)
will do. So please allow me to store
On 14 October 2010 08:34, Jacek Generowicz jacek.generow...@cern.ch wrote:
Those other data might be the functions' arguments, or they might be other
functions with which they are to be combined, or both.
You can represent these as existential packages. However, as Oleg
shows you can always use
Jacek Generowicz jacek.generow...@cern.ch writes:
Let's say I need an Int - String. Both
(fnA2 :: Banana - String) . (fnA1:: Int - Banana)
and
(fnB2 :: Onion - String) . (fnB1 :: Int - Onion)
will do. So please allow me to store (fnA1, fnA2) and (fnB1, fnB2) in
the same place.
On 14 October 2010 08:56, Max Bolingbroke batterseapo...@hotmail.com wrote:
But if the only operation you ever do on this pair is (.), you may as
well skolemise and just store (fnA1 . fnA2) directly. What is the
advantage of doing otherwise?
I forgot to mention that if you *really really* want
On 2010 Oct 14, at 09:19, Evan Laforge wrote:
How
are you expecting to call the functions in that container? for f
in
c: try: return f(*misc_args) except: pass?
to_do = [(call, (AuntMabel,)),
(buy, ([(12*kg, sugar), (6*bushel, wheat)])),
(introduce, (Romeo, Juliet))]
On 2010 Oct 14, at 09:54, Joachim Breitner wrote:
Hi,
Am Donnerstag, den 14.10.2010, 09:34 +0200 schrieb Jacek Generowicz:
Another example:
Let's say I need an Int - String. Both
(fnA2 :: Banana - String) . (fnA1:: Int - Banana)
and
(fnB2 :: Onion - String) . (fnB1 :: Int -
On 2010 Oct 14, at 09:56, Max Bolingbroke wrote:
On 14 October 2010 08:34, Jacek Generowicz
jacek.generow...@cern.ch wrote:
Those other data might be the functions' arguments, or they might
be other
functions with which they are to be combined, or both.
You can represent these as
On 2010 Oct 14, at 09:58, Ketil Malde wrote:
Jacek Generowicz jacek.generow...@cern.ch writes:
Let's say I need an Int - String. Both
(fnA2 :: Banana - String) . (fnA1:: Int - Banana)
and
(fnB2 :: Onion - String) . (fnB1 :: Int - Onion)
will do. So please allow me to store (fnA1,
Jacek Generowicz jacek.generow...@cern.ch writes:
def memoize(fn):
cache = {}
def memoized_fn(*args):
if args not in cache:
cache[args] = fn(*args)
return cache[args]
return memoized_fn
Here's a simplified memoizer for Haskell:
memoize :: (Integral t)
On 2010 Oct 14, at 15:24, Ketil Malde wrote:
Jacek Generowicz jacek.generow...@cern.ch writes:
def memoize(fn):
cache = {}
def memoized_fn(*args):
if args not in cache:
cache[args] = fn(*args)
return cache[args]
return memoized_fn
Here's a simplified memoizer
Thank you all for your contributions so far. Plenty of food for thought.
I though I'd try to put it into practice and have a go at the
motivating example I gave: essentially a EDSL for defining simple
maths tests.
I've included the beginnings of an attempt at the end. It started
Thank you all for your contributions so far. Plenty of food for thought.
I though I'd try to put it into practice and have a go at the motivating
example I gave: essentially a EDSL for defining simple maths tests.
If you have a Python version that has other features you would like, you
On 2010 Oct 13, at 23:52, Evan Laforge wrote:
I admit I haven't read this whole thread in detail, but when I want
something with an implementation that can vary dynamically I just pass
a different function.
Of course.
Your original python example is equivalent to
just passing strings in
I think I'm starting too see what my problem is. I think it boils down to
hankering for Duck Typing and variadic functions. I fully appreciate that
passing functions is a wonderful and powerful technique for catering for
variation, but Haskell's type system cramps my style by insisting that I
On 2010 Oct 14, at 01:32, Evan Laforge wrote:
I think I'm starting too see what my problem is. I think it boils
down to
hankering for Duck Typing and variadic functions. I fully
appreciate that
passing functions is a wonderful and powerful technique for
catering for
variation, but
BTW Thanks: This discussion has helped me gain a better understanding
of some of the mechanisms at work, which I really appreciate.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
If you just want instances of questions you can keep it simple. How about
something isomorphic to
data Instance = Instance { question : String, answer : String, check : String
- Bool }
You could make helper functions similar to your old code, like
addition : (Int , Int) - Instance
You might
On Oct 13, 2010, at 7:44 PM, Jacek Generowicz jacek.generow...@cern.ch wrote:
On 2010 Oct 14, at 01:32, Evan Laforge wrote:
I think I'm starting too see what my problem is. I think it boils down to
hankering for Duck Typing and variadic functions. I fully appreciate that
passing functions is
23 matches
Mail list logo