I think just change

| Some q -> q.Times(number)

to

| Some q -> Some(q.Times(number))

By on 2/22/2009 2:14 AM ()

I works! Thanks so much. I think I got it: Is it a question of consistency then? So, in the first case:

| None -> 1.0 // double

| Some q -> q.Evaluate(point) // double

so the function is infered as double -> double and everything is consistent. However, in the second case:

| None -> None // Option

| Some q -> q.Times(number) // Polynomial

and hence the reported inconsistency solved by

| Some q -> Some(q.Times(number)) // Option

In any case thank you so much; now I can move on with my example.

dfg

PS.- Are definitions of the form _tail : Option considered good practise?

By on 2/22/2009 8:12 AM ()

Exactly.

P.S.: Sometimes. Note that an alternative isomorphic structure for Polynomial would be a list<T> where T is a record of just {Coefficient,Degree}. The advantage of this representation is that you can use things like List.fold_left and List.map on the polynomial representation (indeed, these functions could be used to implement Evaluate and Times respectively).

By on 2/22/2009 12:25 PM ()

What was I thinking?? If lists are given to me with tons of functionality, then why build my own for a trivial type like back in the day when learning C?

I'll try your suggestion; thanks a lot, it seems that with so much new stuff to think about I'm missing the most obvious things.

By on 2/22/2009 5:42 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper