Front Page All Articles Recent Changes Random Article

Contents

Concatenative language

  • ACL
  • Ait
  • Aocla
  • Breeze
  • Callisto
  • Cat
  • Cognate
  • colorForth
  • Concata
  • CoSy
  • Deque
  • DSSP
  • dt
  • Elymas
  • Enchilada
  • ETAC
  • F
  • Factor
  • Fiveth
  • Forth
  • Fourth
  • Freelang
  • Gershwin
  • hex
  • iNet
  • Joy
  • Joy of Postfix App
  • kcats
  • Kitten
  • lang5
  • Listack
  • LSE64
  • Lviv
  • Meow5
  • min
  • Mirth
  • mjoy
  • Mlatu
  • Ode
  • OForth
  • Om
  • Onyx
  • Plorth
  • Popr
  • Porth
  • PostScript
  • Prowl
  • Quest32
  • Quackery
  • r3
  • Raven
  • Retro
  • RPL
  • SPL
  • Staapl
  • Stabel
  • Tal
  • Titan
  • Trith
  • Uiua
  • Worst
  • xs
  • XY
  • 5th
  • 8th

Concatenative topics

  • Compilers
  • Interpreters
  • Type systems
  • Object systems
  • Quotations
  • Variables
  • Garbage collection
  • Example programs

Concatenative meta

  • People
  • Communities

Other languages

  • APL
  • C++
  • Erlang
  • FP trivia
  • Haskell
  • Io
  • Java
  • JavaScript
  • Lisp
  • ML
  • Oberon
  • RPL
  • Self
  • Slate
  • Smalltalk

Meta

  • Search
  • Farkup wiki format
  • Etiquette
  • Sandbox

Fac function

A factorial is a function in mathematics that multiplies a number by every number that precedes it.

int main(){
    int x = 7;
    printf("The factorial of the number is %d", fac(x));
    return 0;
}

int fac(int y)
{
    if (y == 0)
        return 1;
    return y * fac(y - 1);
}

Uxntal

@on-reset ( -> )
	#0007 fac
	#010e DEO
	BRK

@fac ( n* -: res* )
	ORAk ?{ POP2 #0001 JMP2r }
	DUP2 #0001 SUB2 fac MUL2
	JMP2r

Titan

using std.manip
using std.cond
using std.out

fac == [: [/ 1] [: 1 - fac ×] ⍉ 0 = ?]

7 fac .nl

Modal

<> (?0 ?1 `?:) (Int ?:)

<> (?n factorial) (Int ?n Int 1 fact)
<> (Int 0 Int ?a fact) (?a)
<> (Int ?n Int ?a fact) (?n 1 `- ?n ?a `* fact)

6 factorial

This revision created on Thu, 16 May 2024 15:05:50 by neauoire

Latest Revisions Edit

All content is © 2008-2024 by its respective authors. By adding content to this wiki, you agree to release it under the BSD license.