Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Dicken
Post Prodigy
Post Prodigy

Lazy evaluation



Hi i have found this, and think it's dow to  Lazy /eager  evaluation; so  single  empty  list  = {} 

= let alist = {}  ,
tr = List.Transform( alist,(x)=> x {0} ), 
p_indi = alist {0} 
in tr

tr = empty , p_indi = error

But with a nested list ;

= let alist = {{}} ,
tr = List.Transform( alist,(x)=> x {0} ), 
p_indi = alist {0} 
in tr

tr = error, p_indi = empty 

 so if anyone would like to elaborate on why/ how this works, links to info   etc.  please reply,   I have no practical use for this
Just  for the brain. 

Richard. 

1 ACCEPTED SOLUTION
krishnakanth240
Resident Rockstar
Resident Rockstar

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

View solution in original post

4 REPLIES 4
Dicken
Post Prodigy
Post Prodigy

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

AlienSx
Super User
Super User

hi, (x) => x{0} is applied to each element of the list, not the list itself. That's why List.Transform with empty list { } returns the same empty list (nothing to transform) while List.Transform with { { } } returns ... no, not error but the list with single element {error}. And It has nothing to do with lazy / eager evaluation.

krishnakanth240
Resident Rockstar
Resident Rockstar

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

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.