Project

p-lang

0.0
No commit activity in last 3 years
No release in over 3 years
P is a small ('pequena' in portuguese) functional programming language.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

P-Lang¶ ↑

P is a small (‘pequena’ in portuguese) functional programming language.

fib = [1| 1];
      [2| 1];
      [n| fib(n-1) + fib(n-2)]

fib(10)

Features¶ ↑

Functions:

fib = [1| 1];
      [2| 1];
      [n| fib(n-1) + fib(n-2)]

fib(10) # => 55

# or

fib = [1|1]
fib = [2|1]
fib = [n|fib(n-1)+fib(n-2)]

fib(10) # => 55

And more functions:

f = [x| x*pi] : (pi = 3.14)

f(1) # => 3.14

Wildcards

f = [1, _, x| x*2]

f(1,'aaaaa', 10) # => 20

Lists:

x = '(1,2,3,4)
x->head() # => 1
x->tail() # => '(2,3,4)

Objects:

{rectangle: 10, 30}

Pattern:

{rectangle: x, y} = {rectangle: 10, 30}
# => x = 10
# => y = 30

Messages:

{integer: x} -> plus2 = [x+2]

3->plus2() # => 5

IO:

x = read() # <= 123
print(x) # => 123

Requirements¶ ↑

  • Ruby 1.9

Install¶ ↑

$ sudo gem install p-lang

Running¶ ↑

$ p-lang your-program.p

Interactive P Shell¶ ↑

$ p-lang

Note on Patches/Pull Requests¶ ↑

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Ígor Bonadio. See LICENSE for details.