Forum Discussion
Lazy evaluation
- 2 months ago
Hi Dicken
List.Transform operates on empty list {}, so transformation function (x) => x{0} is never executed resulting empty list.alist{0} directly attempts to access first element of an empty list which immediately raises an index out of range error
alist = {{}} contains one element (an empty list). List.Transform execute once passing {} as x and x{0} fails because inner list is empty, so tr becomes an error. alist{0} returns first element of the outer list which is the empty list {}, so no error
so on LIst.Transform( {} , (x)=> , as the list is empt theree is not list for the function to work on,
so it does nothing, stays in that original state, where as {} {0} iis executed regardless, so = error , is this along the right lines.
Yes Dicken
That's how I understand it as well. With List.Transform({}, (x) => x{0}) input list is empty, so there are no elements to pass into function. Since the function is never invoked, nothing attempts to evaluate x{0} and result remains an empty list. {}{0} is a direct indexing operation on an empty list, so it is evaluated immediately and returns an index out of range error