Skip to content

Bad, Interpreted Programming Language

License

Notifications You must be signed in to change notification settings

ArnaudLier/bad-lang-2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bad-lang-2

Basic Example

fn fib(n) {
  let a = 0
  let b = 1
  let temp = 0

  if (#eq(n, 0)) {
    return a
  }

  let i = 2
  loop {
    if (#gt(i, n)) {
      break
    }

    temp = a
    a = b
    b += temp

    i++
  }

  return b
}

io#println(fib(10))

fn factorial(n) {
  if (#eq(n, 0)) {
    return 1
  }

  if (#lt(n, 0)) {
    io#println("Error: Factorial not defined for negative numbers")
    return -1
  }

  let result = 1
  let i = 1

  loop {
    if (#gt(i, n)) {
      break
    }

    result *= i
    i++
  }

  return result
}

io#println(factorial(10))

About

Bad, Interpreted Programming Language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%