Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your definition is a little wrong as it mixes curried and uncurried forms of <code>fibo</code>.</p> <p>If I understand correctly, there's not much to enlighten you about at the level of coding. There's a tiny syntactic difference between the curried and uncurried definitions.</p> <pre><code>- fun plus_uncurried (a, b) = a + b; val plus_uncurried = fn : int * int -&gt; int - plus_uncurried (3,5); val it = 8 : int - fun plus_curried a b = a + b; val plus_curried = fn : int -&gt; int -&gt; int - plus_curried 3 5; val it = 8 : int - val incr = plus_curried 1; val incr = fn : int -&gt; int - incr 4; val it = 5 : int </code></pre> <p>At the conceptual level, curried functions seem a little trickier, at least at first. I personally just think of a curried function as one that returns a function that wants more arguments. When you finally give the last argument you get your answer.</p> <p>(I'm not sure why you tagged this question with OCaml, but in OCaml currying is the idiomatic form for functions. So you get used to it right away.)</p> <p>It may be you're looking for something more complicated than a function of type <code>int -&gt; int -&gt; int seq</code>. If so, you'll need to describe a little more carefully what you're looking for. Just specifying the type of what you're looking for would probably help a lot.</p> <p><strong>Update</strong></p> <p>There's nothing more complicated in <code>fibo</code> than in the examples above, other than that you have a recursive call. If you just change the first part of <code>fibo</code> in the same way that <code>plus_uncurried</code> changes into <code>plus_curried</code>, you will have handled the definition part. To handle the calling part, change your recursive call in the same way that calls to <code>plus_uncurried</code> are changed into calls to <code>plus_curried</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload