You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type List is null | { int data, List next }
function len(List l) -> (int r):
//
int x = 0
// iterate to the end
while !(l is null):
l = l.next
x = x + 1
//
return x
This clarifies a pretty common pattern, where we don't want to explicitly name each bound of a union. Using !(l is null) is ugly and could be replaced with l isnt null.
The text was updated successfully, but these errors were encountered:
Consider the following:
This clarifies a pretty common pattern, where we don't want to explicitly name each bound of a union. Using
!(l is null)
is ugly and could be replaced withl isnt null
.The text was updated successfully, but these errors were encountered: