Sha256: e2d09785b285cb5e62a3f1eaa3dfa84d8eeb7995f2e12bded0be9a8ef35fb121

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

= 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

Copyright (c) 2010 Ígor Bonadio. See LICENSE for details.

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
p-lang-0.3.1 README.rdoc
p-lang-0.3.0 README.rdoc