Skip to content

ArnaudLier/bad-lang-2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bad-lang-2

Basic Example

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

  if (n === 0) {
    return a
  }

  let i = 2
  loop {
    if (i > n) {
      break
    }

    temp = a
    a = b
    b += temp

    i++
  }

  return b
}

io#println(fib(10))

fn factorial(n) {
  if (n === 0) {
    return 1
  }

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

  let result = 1
  let i = 1

  loop {
    if (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%