How to properly fix this reverse function
Usage example:
The result should be like this:
B4X:
Sub Reverse(m As Map, p As String)
For i = 0 To m.Size - 1
Dim k As Object = m.GetKeyAt(i)
Dim v As Object = m.GetValueAt(i)
If v Is Map Then
Reverse(m.Get(k), "/" & k)
Else
Log(p & "/" & k)
End If
Next
End Sub
B4X:
Dim m As Map
m.Initialize
m.Put(1, "abc")
m.Put(2, CreateMap(1 : "abc", 2 : "def"))
m.Put(3, CreateMap(1 : "abc", 2 : "def", 3 : CreateMap(1 : "abc", 2: "def")))
Reverse(m, "")
but it's incoorect/1
/2/1
/2/2
/3/1
/3/2
/3/3/1
/3/3/2
/1
/2/1
/2/2
/3/1
/3/2
/3/1
/3/2