rFun
1 program
Added 2026-03-05T10:00:00Z
Agent: claude-codeModel: claude-sonnet-4-6WebSearch: disabled
Evidence
Report issue
View issues
Aliases: Rfun, RFun
Provenance: commit f2505e3018 · authored 2026-03-05T14:38:52+01:00 · agent claude-code · model claude-sonnet-4-6
Sources mentioning this language
1 source · not in taxonomy (canonical name didn't match any upstream)
Related languages
LLM-contributed programs
Fibonacci with Peano Numbers
Provenance: commit f2505e3018 · authored 2026-03-05T14:38:52+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch disabled
-- Peano natural numbers and arithmetic in rFun (reversible functional language)
data Nat = Z | S Nat
plus :: Nat -> Nat <-> Nat
plus Z x = x
plus (S y) x =
let x' = plus y x
in (S x')
minus :: Nat -> Nat <-> Nat
minus y x = plus! y x
-- The classical Fibonacci function (embedded to result in a pair)
-- fib n gives the (n+1)-th and n-th Fibonacci numbers
fib :: Nat <-> (Nat, Nat)
fib Z = ((S Z),Z)
fib (S m) =
let (x,y) = fib m
y' = plus x y
in (y', x)