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/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Z80_Assembly
Z80 Assembly
org &8000 ld a,'a' ;data ld b,26 ;loop counter ld hl,Alphabet ;destination loop: ld (hl),a ;store "a" into ram inc a ;next letter inc hl ;next storage byte djnz loop ;repeat until 26 letters were stored.   call Moni...
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
#R
R
cat("Hello world!\n")
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#REBOL
REBOL
rebol [ Title: "Functional Composition" URL: http://rosettacode.org/wiki/Functional_Composition ]   ; "compose" means something else in REBOL, therefore I use a 'compose-functions name.   compose-functions: func [ {compose the given functions F and G} f [any-function!] g [any-function!] ] [ func [x] ...
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#REXX
REXX
compose: procedure; parse arg f,g,x; interpret 'return' f"(" g'(' x "))"   exit /*control should never gets here, but this was added just in case.*/
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#Wren
Wren
import "/big" for BigInt, BigRat   var isPowerOfTwo = Fn.new { |bi| bi & (bi - BigInt.one) == BigInt.zero }   var fractran = Fn.new { |program, n, limit, primesOnly| var fractions = program.split(" ").where { |s| s != "" } .map { |s| BigRat.fromRationalString(s) } ...
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 ...
#dc
dc
[*] sm
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Stata
Stata
mata _gamma_coef = 1.0, 5.772156649015328606065121e-1, -6.558780715202538810770195e-1, -4.200263503409523552900393e-2, 1.665386113822914895017008e-1, -4.219773455554433674820830e-2, -9.621971527876973562114922e-3, 7.218943246663099542395010e-3, -1.165167591859065112113971e-3, -2.152416741149509728157300e-4, 1.28050...
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Tcl
Tcl
package require math package require math::calculus   # gamma(1) and gamma(1.5)   set f 1.0 set f2 [expr {sqrt(acos(-1.))/2.}]   for {set x 1.0} {$x <= 10.0} {set x [expr {$x + 0.5}]} {   # method 1 - numerical integration, Romberg's method, special # case for an improper integral   set g1 [math:...
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#zkl
zkl
["a".."z"] // lasy list ["a".."z"].walk() //-->L("a","b","c","d","e",... "a".toAsc().pump(26,List,"toChar") // another way to create the list "a".toAsc().pump(26,String,"toChar") // create a string //-->"abcdefghijklmnopqrstuvwxyz" Utils.Helpers.lowerLetters // string const
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Zig
Zig
const std = @import("std");   pub fn main() !void { const cnt_lower = 26; var lower: [cnt_lower]u8 = undefined; comptime var i = 0; inline while (i < cnt_lower) : (i += 1) lower[i] = i + 'a';   const stdout_wr = std.io.getStdOut().writer(); for (lower) |l| try stdout_wr.print("{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
#Ra
Ra
  class HelloWorld **Prints "Hello world!"**   on start   print "Hello world!"  
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Ring
Ring
  # Project : Function composition   sumprod = func1(:func2,2,3) see sumprod + nl   func func1(func2,x,y) temp = call func2(x,y) res = temp + x + y return res   func func2(x,y) res = x * y return res  
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Ruby
Ruby
def compose(f,g) lambda {|x| f[g[x]]} end s = compose(Math.method(:sin), Math.method(:cos)) p s[0.5] # => 0.769196354841008   # verify p Math.sin(Math.cos(0.5)) # => 0.769196354841008
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#zkl
zkl
var fracs="17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, 77/19, 1/17," "11/13, 13/11, 15/14, 15/2, 55/1"; fcn fractranW(n,fracsAsOneBigString){ //-->Walker (iterator) fracs:=(fracsAsOneBigString-" ").split(",").apply( fcn(frac){ frac.split("/").apply("toInt") }); //( (n,d), (n,d), ...) Walker(fcn(rn,fracs...
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 ...
#Delphi
Delphi
function multiply(a, b: integer): integer; begin result := a * b; end;
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#TI-83_BASIC
TI-83 BASIC
.5! -> .8862269255
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
#Racket
Racket
  (printf "Hello world!\n")  
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Rust
Rust
fn compose<'a,F,G,T,U,V>(f: F, g: G) -> Box<Fn(T) -> V + 'a> where F: Fn(U) -> V + 'a, G: Fn(T) -> U + 'a, { Box::new(move |x| f(g(x))) }
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Scala
Scala
def compose[A](f: A => A, g: A => A) = { x: A => f(g(x)) }   def add1(x: Int) = x+1 val add2 = compose(add1, add1)
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 ...
#Diego
Diego
begin_funct({number}, multiply)_param({number}, a, b); with_funct[]_calc([a]*[b]); end_funct[];   me_msg()_funct(multiply)_param(1,2);
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Visual_FoxPro
Visual FoxPro
  LOCAL i As Integer, x As Double, o As lanczos CLOSE DATABASES ALL CLEAR CREATE CURSOR results (ZVal B(1), GamVal B(15)) INDEX ON zval TAG ZVal COLLATE "Machine" SET ORDER TO 0 o = CREATEOBJECT("lanczos") FOR i = 1 TO 20 x = i/10 INSERT INTO results VALUES (x, o.Gamma(x)) ENDFOR UPDATE results SET GamVal = ROUND(G...
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Vlang
Vlang
import math fn main() { println(" x math.Gamma Lanczos7") for x in [-.5, .1, .5, 1, 1.5, 2, 3, 10, 140, 170] { println("${x:5.1f} ${math.gamma(x):24.16} ${lanczos7(x):24.16}") } }   fn lanczos7(z f64) f64 { t := z + 6.5 x := .99999999999980993 + 676.5...
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
#Raku
Raku
say 'Hello world!';
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Scheme
Scheme
(define (compose f g) (lambda (x) (f (g x))))   ;; or:   (define ((compose f g) x) (f (g x)))   ;; or to compose an arbitrary list of 1 argument functions:   (define-syntax compose (lambda (x) (syntax-case x () ((_) #'(lambda (y) y)) ((_ f) #'f) ((_ f g h ...) #'(lambda (y) (f ((compose g h ......
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Sidef
Sidef
func compose(f, g) { func(x) { f(g(x)) } }   var fg = compose(func(x){ sin(x) }, func(x){ cos(x) }) say fg(0.5) # => 0.76919635484100842185251475805107
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 ...
#Draco
Draco
proc multiply(word a, b) word: a * b corp
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Wren
Wren
import "/fmt" for Fmt import "/math" for Math   var stirling = Fn.new { |x| (2 * Num.pi / x).sqrt * (x / Math.e).pow(x) }   System.print(" x\tStirling\t\tLanczos\n") for (i in 1..20) { var d = i / 10 System.write("%(Fmt.f(4, d, 2))\t") System.write("%(Fmt.f(16, stirling.call(d), 14))\t") System.print("%...
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
#Raven
Raven
'Hello world!' print
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Slate
Slate
[| :x | x + 1] ** [| :x | x squared] applyTo: {3}
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Smalltalk
Smalltalk
| composer fg | composer := [ :f :g | [ :x | f value: (g value: x) ] ]. fg := composer value: [ :x | x + 1 ] value: [ :x | x * x ].   (fg value:3) displayNl.
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 ...
#Dragon
Dragon
func multiply(a, b) { return a*b }
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Yabasic
Yabasic
dim c(12)   sub gamma(z) local accm, k, k1_factrl   accm = c(1) if accm=0 then accm = sqrt(2*PI) c(1) = accm k1_factrl = 1 for k=2 to 12 c(k) = exp(13-k)*(13-k)^(k-1.5)/k1_factrl k1_factrl = k1_factrl * -(k-1) next end if for k=2 to 12...
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#zkl
zkl
fcn taylorGamma(x){ var table = T( 0x1p+0, 0x1.2788cfc6fb618f4cp-1, -0x1.4fcf4026afa2dcecp-1, -0x1.5815e8fa27047c8cp-5, 0x1.5512320b43fbe5dep-3, -0x1.59af103c340927bep-5, -0x1.3b4af28483e214e4p-7, 0x1.d919c527f60b195ap-8, -0x1.317112ce3a2a7bd2p-10, -0x1.c364fe6f1563ce9cp-...
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
#RATFOR
RATFOR
    program hello   write(*,101)"Hello World" 101 format(A)   end    
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Standard_ML
Standard ML
fun compose (f, g) x = f (g x)
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#SuperCollider
SuperCollider
  f = { |x| x + 1 }; g = { |x| x * 2 }; h = g <> f; h.(8); // returns 18  
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 ...
#DWScript
DWScript
function Multiply(a, b : Integer) : Integer; begin Result := 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
#RASEL
RASEL
A"!dlroW ,olleH">:?@,Hj
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Swift
Swift
func compose<A,B,C>(f: (B) -> C, g: (A) -> B) -> (A) -> C { return { f(g($0)) } }   let sin_asin = compose(sin, asin) println(sin_asin(0.5))
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Tcl
Tcl
package require Tcl 8.5 namespace path {::tcl::mathfunc}   proc compose {f g} { list apply [list {f g x} {{*}$f [{*}$g $x]}] $f $g] }   set sin_asin [compose sin asin] {*}$sin_asin 0.5 ;# ==> 0.5 {*}[compose abs int] -3.14 ;# ==> 3
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 ...
#Dyalect
Dyalect
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
#REALbasic
REALbasic
Function Run(args() as String) As Integer Print "Hello world!" Quit End Function
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#TypeScript
TypeScript
  function compose<T, U, V> (fn1: (input: T) => U, fn2: (input: U) => V){ return function(value: T) { return fn2(fn1(value)) } }   function size (s: string): number { return s.length; }   function isEven(x: number): boolean { return x % 2 === 0; }   const evenSize = compose(size, isEven);   console.log...
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#uBasic.2F4tH
uBasic/4tH
Print FUNC(_Compose (_f, _g, 3)) End   _Compose Param (3) : Return (FUNC(a@(FUNC(b@(c@))))) _f Param (1) : Return (a@ + 1) _g Param (1) : Return (a@ * 2)
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 ...
#D.C3.A9j.C3.A0_Vu
Déjà Vu
multiply a b: * a b
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#11l
11l
F isProbablePrime(n, k = 10) I n < 2 | n % 2 == 0 R n == 2   V d = n - 1 V s = 0 L d % 2 == 0 d I/= 2 s++   assert(2 ^ s * d == n - 1)   Int nn I n < 7FFF'FFFF nn = Int(n) E nn = 7FFF'FFFF   L(_) 0 .< k V a = random:(2 .< nn) V x = pow(a, d, n) ...
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
#REBOL
REBOL
print "Hello world!"
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#UNIX_Shell
UNIX Shell
compose() { eval "$1() { $3 | $2; }" }   downvowel() { tr AEIOU aeiou; } upcase() { tr a-z A-Z; } compose c downvowel upcase echo 'Cozy lummox gives smart squid who asks for job pen.' | c # => CoZY LuMMoX GiVeS SMaRT SQuiD WHo aSKS FoR JoB PeN.
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Unlambda
Unlambda
``s`ksk
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 ...
#E
E
def multiply(a, b) { return a * b }
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Arturo
Arturo
firstPrimes: select 1..100 => prime? primorial: function [n][ product first.n: n firstPrimes ]   fortunates: [] i: 1   while [8 > size fortunates][ m: 3 pmi: primorial i while -> not? prime? m + pmi -> m: m+2 fortunates: unique fortunates ++ m i: i + 1 ]   print sort fortunates
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Factor
Factor
USING: grouping io kernel math math.factorials math.primes math.ranges prettyprint sequences sets sorting ;   "First 50 distinct fortunate numbers:" print 75 [1,b] [ primorial dup next-prime 2dup - abs 1 = [ next-prime ] when - abs ] map members natural-sort 50 head 10 group simple-table.
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#FreeBASIC
FreeBASIC
  #include "isprime.bas" #include "sets.bas" #include "bubblesort.bas"   function prime(n as uinteger) as uinteger if n = 1 then return 2 dim as integer c=1, p=3 while c<n if isprime(p) then c+=1 p += 2 wend return p end function   function primorial( n as uinteger ) as ulongint ...
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
#RED
RED
print "Hello world!"
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Ursala
Ursala
compose("f","g") "x" = "f" "g" "x"
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#VBScript
VBScript
  option explicit class closure   private composition   sub compose( f1, f2 ) composition = f2 & "(" & f1 & "(p1))" end sub   public default function apply( p1 ) apply = eval( composition ) end function   public property get formula formula = composition end property   end class  
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 ...
#EasyLang
EasyLang
func multiply a b . r . r = a * b . call multiply 7 5 res print res
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Go
Go
package main   import ( "fmt" "math/big" "rcu" "sort" )   func main() { primes := rcu.Primes(379) primorial := big.NewInt(1) var fortunates []int bPrime := new(big.Int) for _, prime := range primes { bPrime.SetUint64(uint64(prime)) primorial.Mul(primorial, bPrime) ...
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Haskell
Haskell
import Data.Numbers.Primes (primes) import Math.NumberTheory.Primes.Testing (isPrime) import Data.List (nub)   primorials :: [Integer] primorials = 1 : scanl1 (*) primes   nextPrime :: Integer -> Integer nextPrime n | even n = head $ dropWhile (not . isPrime) [n+1, n+3..] | even n = nextPrime (n+1)   fortunateNumbe...
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
#Relation
Relation
  ' Hello world!  
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#WDTE
WDTE
let compose f g => (@ c x => g x -> f);
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Wortel
Wortel
! @[f g] x ; f(g(x))
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 ...
#EchoLisp
EchoLisp
  (define (multiply a b) (* a b)) → multiply ;; (1) (multiply 1/3 666) → 222   ;; a function is a lambda definition : multiply → (λ (_a _b) (#* _a _b))   ;; The following is the same as (1) : (define multiply (lambda(a b) (* a b))) multiply → (🔒 λ (_a _b) (#* _a _b)) ;; a closure     ;; a function may be com...
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#jq
jq
def primes: 2, range(3; infinite; 2) | select(is_prime);   # generate an infinite stream of primorials def primorials: foreach primes as $p (1; .*$p; .);   # Emit a sorted array of the first $limit distinct fortunate numbers # generated in order of the primoridials def fortunates($limit): label $out | foreach p...
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Julia
Julia
using Primes   primorials(N) = accumulate(*, primes(N), init = big"1")   primorial = primorials(800)   fortunate(n) = nextprime(primorial[n] + 2) - primorial[n]   println("After sorting, the first 50 distinct fortunate numbers are:") foreach(p -> print(rpad(last(p), 5), first(p) % 10 == 0 ? "\n" : ""), (map(fortuna...
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
ClearAll[primorials] primorials[n_] := Times @@ Prime[Range[n]] vals = Table[ primor = primorials[i]; s = NextPrime[primor]; t = NextPrime[s]; Min[DeleteCases[{s - primor, t - primor}, 1]] , {i, 100} ]; TakeSmallest[DeleteDuplicates[vals], 50]
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Nim
Nim
import algorithm, sequtils, strutils import bignum   const N = 50 # Number of fortunate numbers. Lim = 75 # Number of primorials to compute.     iterator primorials(lim: Positive): Int = var prime = newInt(2) var primorial = newInt(1) for _ in 1..lim: primorial *= prime prime = prime.nextPrime...
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Perl
Perl
use strict; use warnings; use List::Util <first uniq>; use ntheory qw<pn_primorial is_prime>;   my $upto = 50; my @candidates; for my $p ( map { pn_primorial($_) } 1..2*$upto ) { push @candidates, first { is_prime($_ + $p) } 2..100*$upto; }   my @fortunate = sort { $a <=> $b } uniq grep { is_prime $_ } @candidates;...
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
#ReScript
ReScript
Js.log("Hello world!")
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#Wren
Wren
var compose = Fn.new { |f, g| Fn.new { |x| f.call(g.call(x)) } }   var double = Fn.new { |x| 2 * x }   var addOne = Fn.new { |x| x + 1 }   System.print(compose.call(double, addOne).call(3))
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#zkl
zkl
Utils.Helpers.fcomp('+(1),'*(2))(5) //-->11
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 ...
#Efene
Efene
multiply = fn (A, B) { A * B }   @public run = fn () { io.format("~p~n", [multiply(2, 5)]) }
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Phix
Phix
with javascript_semantics include mpfr.e mpz primorial = mpz_init(1), pj = mpz_init() sequence fortunates = {} for p=1 to 75 do mpz_mul_si(primorial,primorial,get_prime(p)) integer j = 3 mpz_add_si(pj,primorial,3) while not mpz_prime(pj) do mpz_add_si(pj,pj,2) j = j + 2 end while...
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Python
Python
from sympy.ntheory.generate import primorial from sympy.ntheory import isprime   def fortunate_number(n): '''Return the fortunate number for positive integer n.''' # Since primorial(n) is even for all positive integers n, # it suffices to search for the fortunate numbers among odd integers. i = 3 pr...
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
#Retro
Retro
  'Hello_world! s:put  
http://rosettacode.org/wiki/Function_composition
Function composition
Task Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function   f   to the result of applying function   g   to   x. Example compose...
#ZX_Spectrum_Basic
ZX Spectrum Basic
10 DEF FN f(x)=SQR x 20 DEF FN g(x)=ABS x 30 DEF FN c(x)=FN f(FN g(x)) 40 PRINT FN c(-4)
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 ...
#Eiffel
Eiffel
  multiply(a, b: INTEGER): INTEGER do Result := a*b end  
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Raku
Raku
my @primorials = [\*] grep *.is-prime, ^∞;   say display :title("First 50 distinct fortunate numbers:\n"), (squish sort @primorials[^75].hyper.map: -> $primorial { (2..∞).first: (* + $primorial).is-prime })[^50];   sub display ($list, :$cols = 10, :$fmt = '%6d', :$title = "{+$list} matching:\n") { cach...
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#REXX
REXX
/*REXX program finds/displays fortunate numbers N, where N is specified (default=8).*/ numeric digits 12 parse arg n cols . /*obtain optional argument from the CL.*/ if n=='' | n=="," then n= 8 /*Not specified? Then use the default.*/ if cols=='' | cols=="," then...
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
#REXX
REXX
/*REXX program to show a line of text. */ 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 ...
#Ela
Ela
multiply x y = x * y
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Ruby
Ruby
require "gmp"   primorials = Enumerator.new do |y| cur = prod = 1 loop {y << prod *= (cur = GMP::Z(cur).nextprime)} end   limit = 50 fortunates = [] while fortunates.size < limit*2 do prim = primorials.next fortunates << (GMP::Z(prim+2).nextprime - prim) fortunates = fortunates.uniq.sort end   p fortunates[0,...
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Sidef
Sidef
func fortunate(n) { var P = n.pn_primorial 2..Inf -> first {|m| P+m -> is_prob_prime } }   var limit = 50 var uniq = Set() var all = []   for (var n = 1; uniq.len < 2*limit; ++n) { var m = fortunate(n) all << m uniq << m }   say "Fortunate numbers for n = 1..#{limit}:" say all.first(limit)   say "\n...
http://rosettacode.org/wiki/Fortunate_numbers
Fortunate numbers
Definition A Fortunate number is the smallest integer m > 1 such that for a given positive integer n, primorial(n) + m is a prime number, where primorial(n) is the product of the first n prime numbers. For example the first fortunate number is 3 because primorial(1) is 2 and 2 + 3 = 5 which is prime whereas 2 + 2 = 4 ...
#Wren
Wren
import "/math" for Int import "/big" for BigInt import "/sort" for Sort import "/seq" for Lst import "/fmt" for Fmt   var primes = Int.primeSieve(379) var primorial = BigInt.one var fortunates = [] for (prime in primes) { primorial = primorial * prime var j = 3 while (true) { if ((primorial + j).isP...
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
#Ring
Ring
See "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 ...
#Elena
Elena
real multiply(real a, real 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
#Risc-V
Risc-V
.data hello: .string "Hello World!\n\0" .text main: la a0, hello li a7, 4 ecall li a7, 10 ecall  
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 ...
#Elixir
Elixir
defmodule RosettaCode do def multiply(x,y) do x * y end   def task, do: IO.puts multiply(3,5) end   RosettaCode.task
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
#RTL.2F2
RTL/2
TITLE Goodbye World;   LET NL=10;   EXT PROC(REF ARRAY BYTE) TWRT;   ENT PROC INT RRJOB();   TWRT("Hello world!#NL#"); RETURN(1);   ENDPROC;
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 ...
#Elm
Elm
  --There are multiple ways to create a function in Elm   --This is a named function multiply x y = x*y   --This is an anonymous function \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
#Ruby
Ruby
puts "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 ...
#Emacs_Lisp
Emacs Lisp
(defun 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
#Run_BASIC
Run 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 ...
#Erlang
Erlang
% Implemented by Arjun Sunel -module(func_definition). -export([main/0]).   main() -> K=multiply(3,4), io :format("~p~n",[K]).   multiply(A,B) -> case {A,B} of {A, B} -> 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
#Rust
Rust
  fn main() { 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 ...
#ERRE
ERRE
FUNCTION f(x,y,z,…) f=formula 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
#Salmon
Salmon
"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 ...
#Euphoria
Euphoria
function multiply( atom a, atom b ) return a * b 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
#SAS
SAS
/* Using a data step. Will print the string in the log window */ data _null_; put "Hello world!"; run;
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 ...
#F.23
F#
let multiply x y = x * y // integer let fmultiply (x : float) (y : float) = x * y