task_url
stringlengths 30
116
| task_name
stringlengths 2
86
| task_description
stringlengths 0
14.4k
| language_url
stringlengths 2
53
| language_name
stringlengths 1
52
| code
stringlengths 0
61.9k
|
---|---|---|---|---|---|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SASL
|
SASL
|
'Hello World!",nl
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Factor
|
Factor
|
: multiply ( a b -- a*b ) * ;
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Sather
|
Sather
|
class GOODBYE_WORLD is
main is
#OUT+"Hello world!\n";
end;
end;
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Falcon
|
Falcon
|
function sayHiTo( name )
> "Hi ", name
end
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Scala
|
Scala
|
println("Hello world!")
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#FALSE
|
FALSE
|
[*] {anonymous function to multiply the top two items on the stack}
m: {binding the function to one of the 26 available symbol names}
2 3m;! {executing the function, yielding 6}
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Scheme
|
Scheme
|
"Hello world!"
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Fantom
|
Fantom
|
class FunctionDefinition
{
public static Void main ()
{
multiply := |Int a, Int b -> Int| { a * b }
echo ("Multiply 2 and 4: ${multiply(2, 4)}")
}
}
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Scilab
|
Scilab
|
disp("Hello world!");
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Fermat
|
Fermat
|
Func Multiply(a, b) = a*b.
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#ScratchScript
|
ScratchScript
|
print "Hello world!"
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Fexl
|
Fexl
|
\multiply=(\x\y * x y)
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#sed
|
sed
|
i\
Hello world!
q
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Fish
|
Fish
|
2[*]
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Seed7
|
Seed7
|
$ include "seed7_05.s7i";
const proc: main is func
begin
writeln("Hello world!");
end func;
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Forth
|
Forth
|
: fmultiply ( F: a b -- F: c ) F* ;
: multiply ( a b -- c ) * ;
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Self
|
Self
|
'Hello world!' printLine.
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Fortran
|
Fortran
|
XMULTF(X,Y)=X*Y
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SenseTalk
|
SenseTalk
|
put "Hello world!"
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#FreeBASIC
|
FreeBASIC
|
' FB 1.05.0 Win64
Function multiply(d1 As Double, d2 As Double) As Double
Return d1 * d2
End Function
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Set_lang
|
Set lang
|
set ! H
set ! E
set ! L
set ! L
set ! O
set ! 32
set ! W
set ! O
set ! R
set ! L
set ! D
set ! 33
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Free_Pascal
|
Free Pascal
|
function multiply(a, b: integer): integer;
begin
exit(a * b);
end;
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SETL
|
SETL
|
print("Hello world!");
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Frink
|
Frink
|
multiply[x,y] := x*y
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SETL4
|
SETL4
|
out("Hello world!");end
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Futhark
|
Futhark
|
let multiply (x: i32, y: i32) : i32 = x * y
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Shen
|
Shen
|
(output "Hello world!~%")
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#FutureBasic
|
FutureBasic
|
window 1
local fn multiply( a as long, b as long ) as long
end fn = a * b
print fn multiply( 3, 9 )
HandleEvents
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Shiny
|
Shiny
|
say 'Hello world!'
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Gambas
|
Gambas
|
Public Sub Main()
Print Multiply(56, 4.66)
End
Public Sub Multiply(f1 As Float, f2 As Float) As Float
Return f1 * f2
End
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Sidef
|
Sidef
|
„Hello world!”.say;
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#GAP
|
GAP
|
multiply := function(a, b)
return a*b;
end;
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SimpleCode
|
SimpleCode
|
dtxt
Hello world!
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#GML
|
GML
|
#define multiply
a = argument0
b = argument1
return(a * b)
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SIMPOL
|
SIMPOL
|
function main()
end function "Hello world!{d}{a}"
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Gnuplot
|
Gnuplot
|
multiply(x,y) = x*y
# then for example
print multiply(123,456)
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Simula
|
Simula
|
BEGIN
OUTTEXT("Hello world!");
OUTIMAGE
END
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Go
|
Go
|
func multiply(a, b float64) float64 {
return a * b
}
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Sing
|
Sing
|
requires "sio";
public fn singmain(argv [*]string) i32
{
sio.print("hello world !\r\n");
return(0);
}
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Golfscript
|
Golfscript
|
{*}:multiply;
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Sisal
|
Sisal
|
define main
% Sisal doesn't yet have a string built-in.
% Let's define one as an array of characters.
type string = array[character];
function main(returns string)
"Hello world!"
end function
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Groovy
|
Groovy
|
def multiply = { x, y -> x * y }
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SkookumScript
|
SkookumScript
|
print("Hello world!")
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Halon
|
Halon
|
function multiply( $a, $b )
{
return $a * $b;
}
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Slate
|
Slate
|
inform: 'Hello world!'.
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Haskell
|
Haskell
|
multiply x y = x * y
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Smalltalk
|
Smalltalk
|
Transcript show: 'Hello world!'; cr.
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Haxe
|
Haxe
|
function multiply(x:Float, y:Float):Float{
return x * y;
}
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#smart_BASIC
|
smart BASIC
|
PRINT "Hello world!"
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#hexiscript
|
hexiscript
|
fun multiply a b
return a * b
endfun
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SmileBASIC
|
SmileBASIC
|
PRINT "Hello world!"
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#HicEst
|
HicEst
|
FUNCTION multiply(a, b)
multiply = a * b
END
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SNOBOL4
|
SNOBOL4
|
OUTPUT = "Hello world!"
END
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#HolyC
|
HolyC
|
F64 Multiply(F64 a, F64 b) {
return a * b;
}
F64 x;
x = Multiply(42, 13.37);
Print("%5.2f\n", x);
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SNUSP
|
SNUSP
|
/++++!/===========?\>++.>+.+++++++..+++\
\+++\ | /+>+++++++>/ /++++++++++<<.++>./
$+++/ | \+++++++++>\ \+++++.>.+++.-----\
\==-<<<<+>+++/ /=.>.+>.--------.-/
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Hy
|
Hy
|
(defn multiply [a b]
(* a b))
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SoneKing_Assembly
|
SoneKing Assembly
|
extern print
dv Msg Goodbye,World!
mov eax Msg
push
call print
pop
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#i
|
i
|
concept multiply(a, b) {
return a*b
}
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SPARC_Assembly
|
SPARC Assembly
|
.section ".text"
.global _start
_start:
mov 4,%g1 ! 4 is SYS_write
mov 1,%o0 ! 1 is stdout
set .msg,%o1 ! pointer to buffer
mov (.msgend-.msg),%o2 ! length
ta 8
mov 1,%g1 ! 1 is SYS_exit
clr %o0 ! return status is 0
ta 8
.msg:
.ascii "Hello world!\n"
.msgend:
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Icon_and_Unicon
|
Icon and Unicon
|
procedure multiply(a,b)
return a * b
end
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Sparkling
|
Sparkling
|
print("Hello world!");
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#IDL
|
IDL
|
function multiply ,a,b
return, a* b
end
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SPL
|
SPL
|
#.output("Hello world!")
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Inform_6
|
Inform 6
|
[ multiply a b;
return a * b;
];
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SQL
|
SQL
|
SELECT 'Hello world!' text FROM dual;
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Inform_7
|
Inform 7
|
To decide which number is (A - number) multiplied by (B - number):
decide on A * B.
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#SQL_PL
|
SQL PL
|
SELECT 'Hello world!' AS text FROM sysibm.sysdummy1;
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#Ada
|
Ada
|
with Ada.Text_IO,
POSIX.Process_Identification,
POSIX.Unsafe_Process_Primitives;
procedure Fork is
use Ada.Text_IO,
POSIX.Process_Identification,
POSIX.Unsafe_Process_Primitives;
begin
if Fork = Null_Process_ID then
Put_Line ("This is the new process.");
else
Put_Line ("This is the original process.");
end if;
exception
when others =>
Put_Line ("Something went wrong.");
end Fork;
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Io
|
Io
|
multiply := method(a,b,a*b)
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Standard_ML
|
Standard ML
|
print "Hello world!\n"
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#Aikido
|
Aikido
|
var pid = fork()
switch (pid) {
case <0:
println ("fork error")
break
case 0:
println ("child")
break
default:
println ("parent")
break
}
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#ALGOL_68
|
ALGOL 68
|
main:
(
INT pid;
IF (pid:=fork)=0 THEN
print("This is new process")
ELIF pid>0 THEN
print("This is the original process")
ELSE
print("ERROR: Something went wrong")
FI
)
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#IWBASIC
|
IWBASIC
|
'1. Not Object Oriented Program
DECLARE Multiply(N1:INT,N2:INT),INT
DEF A,B:INT
A=2:B=2
OPENCONSOLE
PRINT Multiply(A,B)
PRINT
'When compiled as a console only program, a press any key to continue is automatic.
CLOSECONSOLE
END
SUB Multiply(N1:INT,N2:INT),INT
DEF Product:INT
Product=N1*N2
RETURN Product
ENDSUB
'Can also be written with no code in the subroutine and just RETURN N1*N2.
----
'2. Not Object Oriented Program Using A Macro
$MACRO Multiply (N1,N2) (N1*N2)
DEF A,B:INT
A=5:B=5
OPENCONSOLE
PRINT Multiply (A,B)
PRINT
'When compiled as a console only program, a press any key to continue is automatic.
CLOSECONSOLE
END
----
'3. In An Object Oriented Program
CLASS Associate
'functions/methods
DECLARE Associate:'object constructor
DECLARE _Associate:'object destructor
'***Multiply declared***
DECLARE Multiply(UnitsSold:UINT),UINT
'members
DEF m_Price:UINT
DEF m_UnitsSold:UINT
DEF m_SalesTotal:UINT
ENDCLASS
DEF Emp:Associate
m_UnitsSold=10
Ass.Multiply(m_UnitsSold)
OPENCONSOLE
PRINT"Sales total: ",:PRINT"$"+LTRIM$(STR$(Emp.m_SalesTotal))
PRINT
CLOSECONSOLE
END
'm_price is set in constructor
SUB Associate::Multiply(UnitsSold:UINT),UINT
m_SalesTotal=m_Price*UnitsSold
RETURN m_SalesTotal
ENDSUB
SUB Associate::Associate()
m_Price=10
ENDSUB
SUB Associate::_Associate()
'Nothing to cleanup
ENDSUB
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Stata
|
Stata
|
display "Hello world!"
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#AutoHotkey
|
AutoHotkey
|
MsgBox, 4, Fork, Start another process?
IfMsgBox, Yes
Run, %A_AhkPath% "%A_ScriptFullPath%"
MsgBox, 0, Fork, Stop this process.
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#BaCon
|
BaCon
|
' Fork
pid = FORK
IF pid = 0 THEN
PRINT "I am the child, my PID is:", MYPID
ENDFORK
ELIF pid > 0 THEN
PRINT "I am the parent, pid of child:", pid
REPEAT
PRINT "Waiting for child to exit"
SLEEP 50
UNTIL REAP(pid)
ELSE
PRINT "Error in fork"
ENDIF
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#J
|
J
|
multiply=: *
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Suneido
|
Suneido
|
Print("Hello world!")
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#Batch_File
|
Batch File
|
@echo off
if "%1" neq "" goto %1 || echo Not a valid subroutine
echo Starting mySubroutine1
start "" "%~n0" mySubroutine1
echo.
echo Starting mySubroutine2 6 3
start "" "%~n0" mySubroutine2 6 3
echo.
echo Starting mySubroutine3
start "" "%~n0" mySubroutine3
echo.
:: We wait here for the subroutines to run, but they are running asynchronously
timeout /t 1
for /l %%i in (1,1,3) do (
for /f "tokens=*" %%j in (output%%i.txt) do (
set output%%i=%%j
del output%%i.txt
)
)
echo.
echo.
echo Return values
echo ----------------------------
echo mySubroutine1: %output1%
echo mySubroutine2: %output2%
echo mySubroutine3: %output3%
pause>nul
exit
:mySubroutine1
echo This is the result of subroutine1 > output1.txt
exit
:mySubroutine2
set /a result=%2+%3
echo %result% > output2.txt
exit
:mySubroutine3
echo mySubroutine1 hasn't been run > output3.txt
if exist output1.txt echo mySubroutine1 has been run > output3.txt
exit
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Java
|
Java
|
public class Math
{
public static int multiply( int a, int b) { return a*b; }
public static double multiply(double a, double b) { return a*b; }
}
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Swahili
|
Swahili
|
andika("Hello world!")
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#C
|
C
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <err.h>
int main()
{
pid_t pid;
if (!(pid = fork())) {
usleep(10000);
printf("\tchild process: done\n");
} else if (pid < 0) {
err(1, "fork error");
} else {
printf("waiting for child %d...\n", (int)pid);
printf("child %d finished\n", (int)wait(0));
}
return 0;
}
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#C.23
|
C#
|
using System;
using System.Threading;
namespace Fork {
class Program {
static void Fork() {
Console.WriteLine("Spawned Thread");
}
static void Main(string[] args) {
Thread t = new Thread(new ThreadStart(Fork));
t.Start();
Console.WriteLine("Main Thread");
t.Join();
Console.ReadLine();
}
}
}
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#JavaScript
|
JavaScript
|
function multiply(a, b) {
return a*b;
}
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Swift
|
Swift
|
print("Hello world!")
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#C.2B.2B
|
C++
|
#include<iostream>
#include<unistd.h>
int main()
{
pid_t pid = fork();
if (pid == 0)
{
std::cout << "This is the new process\n";
}
else if (pid > 0)
{
std::cout << "This is the original process\n";
}
else
{
std::cerr << "ERROR: Something went wrong\n";
}
return 0;
}
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#Clojure
|
Clojure
|
(require '[clojure.java.shell :as shell])
(shell/sh "echo" "foo") ; evaluates to {:exit 0, :out "foo\n", :err ""}
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Joy
|
Joy
|
DEFINE multiply == * .
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#jq
|
jq
|
def multiply(a; b): a*b;
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Symsyn
|
Symsyn
|
'hello world' []
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#COBOL
|
COBOL
|
identification division.
program-id. forking.
data division.
working-storage section.
01 pid usage binary-long.
procedure division.
display "attempting fork"
call "fork" returning pid
on exception
display "error: no fork linkage" upon syserr
end-call
evaluate pid
when = 0
display " child sleeps"
call "C$SLEEP" using 3
display " child task complete"
when < 0
display "error: fork result not ok" upon syserr
when > 0
display "parent waits for child..."
call "wait" using by value 0
display "parental responsibilities fulfilled"
end-evaluate
goback.
end program forking.
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#Common_Lisp
|
Common Lisp
|
(let ((pid (sb-posix:fork)))
(cond
((zerop pid) (write-line "This is the new process."))
((plusp pid) (write-line "This is the original process."))
(t (error "Something went wrong while forking."))))
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Julia
|
Julia
|
function multiply(a::Number, b::Number)
return a * b
end
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Tailspin
|
Tailspin
|
'Hello World' -> !OUT::write
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#D
|
D
|
import core.thread;
import std.stdio;
void main() {
new Thread({
writeln("Spawned thread.");
}).start;
writeln("Main thread.");
}
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#DCL
|
DCL
|
$! looper.com procedure
$ i = 10
$ loop:
$ show time
$ wait 'p1
$ i = i - 1
$ if i .gt. 0 then $ goto loop
|
http://rosettacode.org/wiki/Function_definition
|
Function definition
|
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Task
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
Related task
Function prototype
|
#Kaya
|
Kaya
|
program test;
// A function definition in Kaya:
Int multiply(Int a, Int b) {
return a * b;
}
// And calling a function:
Void main() {
putStrLn(string( multiply(2, 3) ));
}
|
http://rosettacode.org/wiki/Hello_world/Text
|
Hello world/Text
|
Hello world/Text is part of Short Circuit's Console Program Basics selection.
Task
Display the string Hello world! on a text console.
Related tasks
Hello world/Graphical
Hello world/Line Printer
Hello world/Newbie
Hello world/Newline omission
Hello world/Standard error
Hello world/Web server
|
#Tcl
|
Tcl
|
puts "Hello world!"
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#Delphi
|
Delphi
|
program Fork_app;
{$APPTYPE CONSOLE}
uses
System.Threading;
procedure Fork;
begin
Writeln('Spawned Thread');
end;
var
t: ITask;
begin
t := TTask.Run(fork);
Writeln('Main Thread');
TTask.WaitForAll(t);
Readln;
end.
|
http://rosettacode.org/wiki/Fork
|
Fork
|
Task
Spawn a new process which can run simultaneously with, and independently of, the original parent process.
|
#Elixir
|
Elixir
|
defmodule Fork do
def start do
spawn(fn -> child end)
IO.puts "This is the original process"
end
def child, do: IO.puts "This is the new process"
end
Fork.start
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.