Parametric polymorphism: Difference between revisions

Added FreeBASIC
m (→‎{{header|C++}}: formatting and nullptr instead of NULL)
(Added FreeBASIC)
Line 493:
# value: <tree></syntaxhighlight>
 
=={{header|F_Sharp|F#FreeBASIC}}==
{{trans|Visual Basic .NET}}
FreeBASIC does not support object-oriented programming, so we will use a more procedural approach.
<syntaxhighlight lang="vbnet">Type BinaryTree
valor As Integer
izda As BinaryTree Ptr
dcha As BinaryTree Ptr
End Type
 
Sub PrintTree(t As BinaryTree Ptr, depth As Integer)
If t = 0 Then Exit Sub
Print String(depth, Chr(9)); t->valor
PrintTree(t->izda, depth + 1)
PrintTree(t->dcha, depth + 1)
End Sub
 
Dim As BinaryTree b = Type(6)
Dim As BinaryTree bLeft = Type(5)
Dim As BinaryTree bRight = Type(7)
b.izda = @bLeft
b.dcha = @bRight
 
PrintTree(@b, 0)</syntaxhighlight>
 
=={{header|F_Sharp|F#}}==
<syntaxhighlight lang="fsharp">
namespace RosettaCode
2,122

edits