Browsing projects by Tag(s)

Select a tag to browse associated projects and drill deeper into the tag cloud.

Showing page 1 of 1

UFO is a general-purpose multi-paradigm functional programming language with some very high-level features. Some of the more specific features make it quite suitable for creating other programming languages and computational models (abstract/virtual machines). It includes: automatic memory ... [More] management a number of high-level concurrency constructs with garbage collected threads extensive pattern matching capabilities easy to use syntax (it is not a curly-brace-and-semicolon programming language) strong, dynamic typing lots of built-in data structures even more! The UFO language borrows heavily from just about every functional language in existence, most notably Scheme, Postscript, Erlang, Haskell, ML, Oz, and probably a few others. The language is being developed in Modula-3 using the CM3 compiler. The language is currently in the alpha stage (March 2009), so I am not releasing any source code. Once it reaches the beta stage I will provide the source code here. I anticipate that happening Real Soon Now (TM), which is why I have created this web page. Until then, see http://ufo.wikispaces.com. [Less]

0
 
  0 reviews  |  0 users  |  0 current contributors
 
 

Funk is a scripting language that is very simple at it's core: It has functions (as values), pattern matching and real variables. That's it - the rest is just nice notation for defining different kinds of functions - every value is a function. Object oriented programming is implemented via ... [More] pattern matching, and the notation is shorter than most other dynamic (and static) languages. Implementation statusThe current implementation is written in the OCaml language and translates the language into OCaml. It also requires ExtLib. Please use a Subversion client to check out the source if you want to play around with it. Modules and standard libraries are not implemented at this point, since I'm thinking about moving the language to the Neko platform and use NekoML instead of OCaml. I am currently working on a new vesion of Funk, which simplifies the existing syntax and adds optional type annotations (with inference). I hope to release a new version late this year (2009). A short introductionThe details aren't entirely accurate, see the Reference for specifics. :fib { |0| 0 |1| 1 |n| fib(n - 1) + fib(n - 2) }This is a naive implementation of the Fibonacci function (returns element n in the sequence 1, 1, 2, 3, 5, 8, 13, 21, ...). It uses a simple form of pattern matching: if the argument matches the pattern 0, that is, if it is zero, the function returns zero. If the argument matches 1, it returns one, and otherwise it calls itself to find the answer. :point {|x y| { |X| x |Y| y |Add p| point(x + p.X, y + p.Y) |ToString| "("..x..", "..y..")" }}The above is a constructor function that constructs a point (x, y). The first thing to notice is the |x y| pattern. It simply says that the parameter takes two arguments, x and y. The interesting part is what it returns - a new object. This new object has methods X and Y that returns the x and y that the constructor was called with (notice that those arguments are never forgotten in the entirety of the constructed objects lifetime). The Add method takes an argument p, which is a point, and returns a new point with coordinates that are the sums of the individual coordinates of this point and the p point. The ToString method simply returns a nice string representation of the point. :p1 point(5, 7) # let p1 be the point (5, 7) :p2 point(2, 3) # let p2 be the point (2, 3) print p1.X # prints "5" print p1.Add(p2) # prints "(7, 10)"This example shows the basics of how to define variables and how to call methods (oh yeah, and line comments begin with a hash (#) and are ignored). Apart from the colon syntax for defining variables, it should be straightforward if you already know OOP. If not, don't worry, I'll explain it without reference to OOP later on. There are no keywords in Funk. No if, no while and no print. The if statement has what must seem like a rather peculiar replacement in this language: (x > 42).Then({print "x is great!"})As you may have guessed, this reads "if x is greater than 42, then print >>x is great!<s an unusual implementation. [Less]

0
 
  0 reviews  |  0 users  |  292 lines of code  |  0 current contributors  |  Analyzed 3 days ago
 
 

A framework for writing extensions to OCaml pattern matching. Examples included with the distribution: Pattern-matching for lazy values Conjunctive patterns Conjunctive patterns (as found in F#) generalise "as"-patterns. In standard OCaml the syntax `patt as var' may be used to ... [More] bind a value simultaneously to both a pattern and a variable; with conjunctive patterns the syntax `patt & patt' may be used to bind a value simultaneously to two patterns. For example, let ((`A a, b) & (c, `B d)) = (`A 3, `B 4) in (a,b,c,d)evaluates to (3, `B 4, `A 3, 4)Object patterns Object patterns bind the results of calling an object's methods to other patterns during a pattern match. This makes it more convenient to use objects as structurally-typed records. The notation mirrors that in Jacques Garrigue's pa_oo extension. For example, let {| x = x; y = _ |} = object method x = 3 method y = 4 method z = 5 end in x + 1evaluates to 4Negative patterns Matching with negative patterns succeeds if the value does not match the pattern given. For example, let nonzero = function | ~0 -> true | _ -> false in (nonzero 4, nonzero 0)evaluates to (true, false)N+K patterns The infamous n+k patterns (as found in Haskell) offer a "Peano-number" view of integers. Matching an integer value v against `patt+k' (where k is an integer literal) succeeds, binding patt to v-k, if v>=k. For example let pred = function | x+1 -> x | 0 -> 0 in (pred 10, pred 0)evaluates to (9, 0) Release 0.3 included pattern guards which are gone for now, but should reappear in a future release. Links: Download source Documentation Announcement (v 0.1) Announcement (v 0.2) Announcement (v 0.3) Announcement (v 0.4) [Less]

0
 
  0 reviews  |  0 users  |  0 current contributors  |  Analyzed 6 days ago
 
 
 
 

Creative Commons License Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.