summing elements from a user defined datatype
问题 Upon covering the predefined datatypes in f# (i.e lists) and how to sum elements of a list or a sequence, I'm trying to learn how I can work with user defined datatypes. Say I create a data type, call it list1: type list1 = A | B of int * list1 Where: A stands for an empty list B builds a new list by adding an int in front of another list so 1,2,3,4, will be represented with the list1 value: B(1, B(2, B(3, B(4, A)))) From the wikibook I learned that with a list I can sum the elements by doing