Sums a list of integers.
- Produces an
ArgumentExceptionfor an empty list. - It would be better if we'd use
List.foldwith a0, so it doesn't throw upon an empty list.
> let somelist = [1;2;3;4];;
> listsum somelist;;
val it : int = 10
> listsum [];;
System.ArgumentException...
> listsum [4;5];;
val it : int = 9In a codeblock:
- If the source line starts with
>:- execute it and store the output lines
- If a source line doesn't start with
>:- If the source line ends with
...compare everything in front of it with the current output line - If it doesn't, compare the source line with the current output line
- If the source line ends with
- go to the next output line & source line
The fsharp code tags could be easily tested like this, and not a lot of extra parsing is needed (as opposed to your code).