# Surprising result using operator form of FoldList [closed]

I was trying to implement some Graph related functions in Functional form and came accross this result which I found surprising.

I want a function that does various operations on a graph.

The simplest operation is Identity which could simply count the number of nodes in the graph.

Somehow this function does exactly that.

Fold[1 + #&][1,{a,b,c,d}]


giving:

5


And the corollary result which shows how it works:

FoldList[1 + #&][1,{a,b,c,d}]


giving:

{1, 2, 3, 4, 5}


The two questions that arise are:

1. Can this result be explained in an intuitive fashion ?
2. Can this idea be used to perform more complex operations on the graph ?
• Did you forget a }? Or did you have a { too much? – C. E. Dec 22 '18 at 21:25
• FoldList >> Properties and Relations : Functions that ignore their second argument give the same result as in NestList. Similarly for Fold. – kglr Dec 22 '18 at 21:40
• @C.E. Thanks for pointing this out. I removed the superfluous {. – v1j4y Dec 23 '18 at 0:33
• @kglr Ah yes, reading the docs. Thanks a lot. I learned my first lesson the hard way ! Althouth this is such an obfuscated way to count the length of a list :-P – v1j4y Dec 23 '18 at 0:36