Підпрограма: відмінності між версіями
[перевірена версія] | [перевірена версія] |
Вилучено вміст Додано вміст
м вилучена Категорія:Підпрограмми; додана Категорія:Підпрограми за допомогою HotCat |
|||
Рядок 25:
Особливий випадок представляє [[Процедура рекурсивна|рекурсивна процедура]] та процедура без параметрів, виклик якої містить лише її ідентифікатор.
== Приклади підпрограм (функций) ==
=== JavaScript ===
<source lang="javascript">
function name(text, element)
{
document.getElementById(element).innerHTML = text;
}
</source>
=== ActionScript ===
<source lang="actionscript">
public function name(text: string)
{
var textfield: TextField = new TextField();
textfield.text = text;
}
</source>
=== С++ ===
<source lang="cpp">
void name(string text)
{
cout << text;
}
</source>
=== C# ===
<source lang="csharp">
public void name(string text)
{
System.Console.WriteLine(text);
}
</source>
=== Pascal ===
<source lang="pascal">
procedure name(var text: string)
begin
write(text);
end;
</source>
=== PHP ===
<source lang="php">
function name($text)
{
echo $text;
}
</source>
=== Standard ML ===
<source lang="ocaml">
fun name t = print t
</source>
або, теж саме (див. [[Функція першого класу]] и [[лямбда-функція]]):
<source lang="ocaml">
val name = fn t => print t
</source>
=== Visual Basic ===
<source lang="vb">
Sub Name(text)
Console.WriteLine(text)
End Sub
</source>
=== PureBasic ===
<source lang="purebasic">
Procedure.l Name(text.s)
PrintN(text)
EndProcedure
</source>
=== Python ===
<source lang="python3">
def func(text):
print(text)
</source>
== Див. також ==
|