Me misunderstanding actually.  I'd forgotten the foldr.  The answer is that foldr calls your folding function multiple times, do you don't need to worry about it.<span></span><br><br>On Monday, November 10, 2014, Roelof Wobben <<a href="mailto:r.wobben@home.nl">r.wobben@home.nl</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>Julian Birch schreef op 10-11-2014
      20:41:<br>
    </div>
    <blockquote type="cite"><br>
      Consider what happens if you apply the last function to xs.
      <div><span></span><br>
      </div>
    </blockquote>
    <br>
    Then you get the last item but fold supposes to run over all items.
    <br>
    <br>
    Or do I misunderstood the question.<br>
    <br>
    Roelof<br>
    <br>
    <br>
    <br>
    <br>
    <blockquote type="cite">
      <div>On Monday, November 10, 2014, Roelof Wobben <<a href="javascript:_e(%7B%7D,'cvml','r.wobben@home.nl');" target="_blank">r.wobben@home.nl</a>>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Of course
          the compiler is right.<br>
          <br>
          Im still struggeling.<br>
          <br>
          What I try to do is this<br>
          <br>
          1) if acc is empty then a empty list so the output must be
          Nothing<br>
          2) if the input has only one item then it is the last so the
          output must be that item.<br>
          3) if the input has more then 1item then the last item is not
          reached so acc must have the value of the next item of the
          input file<br>
          <br>
          And I do not see how I can give acc the value of the next
          value of the input file maybe head xs<br>
          <br>
          Roelof<br>
          <br>
          <br>
          Leza Morais Lutonda schreef op 10-11-2014 19:52:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            Hi Roelof,<br>
            <br>
            On 10/11/14 10:10, Roelof Wobben wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              No problem .<br>
              <br>
              Im strugelling to make acc work.<br>
              <br>
              I try to say that if the input list has only 1 item the
              outcome is the head of that list.<br>
              But doing<br>
              <br>
              acc = Just (head a)  or doing acc = Just (head acc) gives
              both that acc or a is not in scope<br>
            </blockquote>
            The `a` in the type signature `acc :: a -> Maybe a ->
            Maybe a` is not a variable name, it is a type.<br>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <br>
              also doing acc x = Just (head x) gives a error messages
              that the types are not matching.<br>
            </blockquote>
            :t Just (head x)<br>
            Maybe a<br>
            <br>
            :t acc x<br>
            Maybe a -> Maybe a<br>
            <br>
            So, the compiler is right!<br>
            <br>
            <br>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <br>
              Roelof<br>
              <br>
              <br>
              <br>
            </blockquote>
            <br>
            <br>
          </blockquote>
          <br>
          _______________________________________________<br>
          Beginners mailing list<br>
          <a>Beginners@haskell.org</a><br>
          <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
        </blockquote>
      </div>
      <br>
      <br>
      -- <br>
      Sent from an iPhone, please excuse brevity and typos.<br>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
Beginners mailing list
<a href="javascript:_e(%7B%7D,'cvml','Beginners@haskell.org');" target="_blank">Beginners@haskell.org</a>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a>
</pre>
    </blockquote>
    <br>
  </div>

</blockquote><br><br>-- <br>Sent from an iPhone, please excuse brevity and typos.<br>