Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COThanks! I am still a little confused though. I understand that because SML is functional it will resolve everything to the base case before it starts to run the function `'f` and that my return type `'b` is going to be something like `(r1: list, r2: int)` with r1 being the list of elements and r2 the height. I am still not sure how to specifically compare the "left" r2 to the "right" r2 and then subsequently pass the "correct" r1 up. (Which I guess really is the meat of the issue still...) Thanks again for your help!
      singulars
    2. COLet's say your function `f` is being called with the argument `((left_elements, left_depth), x, (right_elements, right_depth))`. Now, if `left_depth > right_depth`, you keep your `left_elements` for your new result, and increase depth by 1. Vice versa if `left_depth < right_depth`. In case `left_depth = right_depth`, combine your `left_elements` and `right_elements` lists, since the exercise asked to return all elements of the maximum depth.
      singulars
    3. COAh, I feel so dumb right now... I've updated my solution attempt above but it is now giving me an error on `if left_dep > right_dep then (left_ele, left_dep+1) else (right_ele, right_dep+1)` saying that types of if branches do not agree. I would just declare a type with left_elements:int list for example but it has to handle both integers and strings interchangeably. Am I at least on the right path?
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload