
-----------------------------------
Cervantes
Sun May 21, 2006 9:53 pm

Turing as a Functional Programming Language
-----------------------------------
Turing as a Functional Programming Language
(Partly.)

What is a functional programming language?

Let's got to wikipedia on that one.

Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions. Functional programming emphasizes the definition of functions rather than the implementation of state machines, in contrast to procedural programming, which emphasizes the execution of sequential commands. A purely functional program does not use mutation: rather than modifying state to produce values (as is done in imperative programming), it constructs new values from (but does not overwrite) existing values.

There is no uniform agreement on what constitutes functional programming or a functional programming language. Often considered important are first-class functions (including anonymous functions), closures, and recursion. Other common features of functional programming languages are continuations, Hindley-Milner type inference systems, non-strict evaluation (i.e. "laziness") or explicit suspensions, and monads.

If you survived that, bravo! Now I'll restate the important points (for us).

Functional programming is a programming paradigm that often thought as opposite to procedural programming. Functions in a functional language may appear similar to functions in other languages, such as Turing; however, functions in a functional language are much closer to the mathematical definition of a function. That is, a function takes one value and returns another value, based on the given value. For example, f(x) = x^2 is a function that defines a parabola.

Functions in a functional language can still take multiple parameters, however. But they work a little differently. Let's take the equation of a plane, f(x, y) = x + y. If x is the x axis, y is the y axis, and f(x, y) is the z axis, you get a plane that contains the lines z = x and z = y. Now, in terms of a functional language, this function is taking two parameters and that's not good. This is allowed, but what really goes on behind the scenes is this function that takes two parameters is turned into a function that takes one parameter. This function that takes one parameter returns another function that takes one parameter. This new function that takes one parameter, finally, returns our value.

I said something funny there, didn't I? I said that our function returned another function. How can a function return a function? This is possible because functions in a functional language are first-class values, just like integers or strings. This means that our original function can -- instead of returning a real number -- return another function, because functions are first-class values.

Functions as first-class values raises two important points. 

Functions can be anonymous. We don't need to give every function we make a name.
Functions can be passed to other functions as values. This is really what this tutorial is about.



Functions as parameters

Consider the task of finding a root of a function. 
function findRoot (low, high, incriment : real) : real
    % Find the first root of the function f(x) = x^2 - 4
    % starting from 'low' and ending at 'high'.
    var x := low
    loop
        exit when x > high
        % The rounding here is to avoid things like
        % 0.000000000023345 not equalling 0
        if round ((x ** 2 - 4) / incriment) = 0 then
            result x
        end if
        x += incriment
    end loop
    % No root was found for the function f(x) = x^2 - 4
    % between x = low and x = high
    % Return a signal that no root was found.
    result minint
end findRoot

put "The first root that I found between -10 and 10 for the function f(x) = x**2 - 4 is: ", findRoot (-10, 10, 0.1)


But we can do better. Our 'findRoot' function isn't very useful if it only deals with one hardcoded function, f(x) = x^2 - 4. To make it really useful, our 'findRoot' function should take another function as a parameter. This parameter will be the function whose root will be found.
Here we go. I'm really going to do it. Passing functions as parameters. Just let me put on my wizard robe and pick up my magic wand.
I'll bet some of you have been reading this and thinking none of it will actually be possible in Turing. Never say "never".

function findRoot (f : function f (x : real) : real, low, high, incriment : real) : real
    % Find the first root of the function f(x)
    % starting from 'low' and ending at 'high'.
    var x := low
    loop
        exit when x > high
        % The rounding here is to avoid things like
        % 0.000000000023345 not equalling 0
        if round (f (x) / incriment) = 0 then
            result x
        end if
        x += incriment
    end loop
    % No root was found for the function f(x) = x^2 - 4
    % between x = low and x = high
    % Return a signal that no root was found.
    result minint
end findRoot

function f (x : real) : real
    result x ** 2 - 4
end f
put "The first root that I found between -10 and 10 for the function f(x) = x**2 - 4 is: ", findRoot (f, -10, 10, 0.1)

Press F1. ... Success!

There you have it. Functions in Turing can be passed as parameters.

Now some notes:

The function parameter in our 'findRoot' function is 'f'. That is, our function is called 'f'. This does not mean that the parameter type -- function f (x : real) : real -- has to use 'f' as the function name. The following is also valid, for example:
function findRoot (f : function g (x : real) : real, low, high, incriment : real) : real
There is an alternative syntax to do this. It's essentially the same, but without the initial 'f :' in 'f : function ...'. For example,
function findRoot (function f (x : real) : real, low, high, incriment : real) : real
To the best of my knowledge (which, with regard to functionalism in Turing, has been put together in one night), we cannot anonymously create functions. That is, we must define our function f(x) as per usual before calling our 'findRoot' function, then pass f(x) into 'findRoot'.



Another (more useful) example to digest

Who likes Calculus? I know I do. To that end, I made a very brief 'Calculus' module. It defines two functions: one to find the slope of a given function at a given x value, and one to find the area "under the curve" of the given function between the given x values.


module Calculus
    export slope, area
    function slope (f : function f (x : real) : real, x : real) : real
        const accuracy := 0.00000001
        result (f (x + accuracy) - f (x - accuracy)) / (accuracy * 2)
    end slope
    function area (f : function f (x : real) : real, low, high, width : real) : real
        if high - low  value_at (3)

This gets the third element from the array, and it looks just like a method call. Pretty sweet, huh? Now, onwards and upwards, my friends! We're going to add a whole bunch of really cool methods to this IntArray class.

First, I will define a helper method, push. This accepts one argument and pushes it onto the top of the array. It is defined like this:

    proc push (value : int)
        n += 1
        value_at (n) := value
    end push

You'll only see the push method appear in the code later, when I define the map and delete_if methods.

The first interesting method is create, which is used to initialize the array. It takes two parameters. The first is the number of elements the array will store. The second parameter, however, is a function f that takes one integer argument and returns another integer. The idea is that the nth element of the array will be set to f(n). Here is the code:

class IntArray
    export var value_at, create
    var value_at : array 1 .. 1000 of int
    var n := 0
    proc create (num_of_elements : int, f : function f (x : int) : int)
        n := num_of_elements
        for i : 1 .. num_of_elements
            value_at (i) := f (i)
        end for
    end create
end IntArray

var first_arr : ^IntArray
new IntArray, first_arr

function factorial (n : int) : int
    if n < 2 then
        result 1
    else
        result n * factorial (n - 1)
    end if
end factorial
first_arr -> create (4, factorial)	% This reads quite nicely: "create 4 factorials"


What is in our array, now that we've created it with a factorial function? If you've done the math, you'd know that the array holds each, comes in.

each is our iteration method. It takes each element of our array and performs an action on it. The action that it performs is determined by the procedure that you pass to each. Here is the code:

class IntArray
    export var value_at, create, each
    var value_at : array 1 .. 1000 of int
    var n := 0
    proc create (num_of_elements : int, f : function f (x : int) : int)
        n := num_of_elements
        for i : 1 .. num_of_elements
            value_at (i) := f (i)
        end for
    end create
    proc each (do : procedure do (x : int))
        for i : 1 .. n
            do (value_at (i))
        end for
    end each
end IntArray

var first_arr : ^IntArray
new IntArray, first_arr

function factorial (n : int) : int
    if n < 2 then
        result 1
    else
        result n * factorial (n - 1)
    end if
end factorial
first_arr -> create (4, factorial)

proc print (x : int)
    put x, " " ..
end print
first_arr -> each (print)


1 2 6 24


What if we want to iterate through each element of our array, but still have the index by our side? We'll make a new method, each_with_index, whose procedure takes two parameters, x and i, which represent the element and the index, respectively. Here is the code:

class IntArray
    export var value_at, create, each_with_index
    var value_at : array 1 .. 1000 of int
    var n := 0
    proc create (num_of_elements : int, f : function f (x : int) : int)
        n := num_of_elements
        for i : 1 .. num_of_elements
            value_at (i) := f (i)
        end for
    end create
    proc each_with_index (do : procedure do (x, i : int))
        for i : 1 .. n
            do (value_at (i), i)
        end for
    end each_with_index
end IntArray

var first_arr : ^IntArray
new IntArray, first_arr

function factorial (n : int) : int
    if n < 2 then
        result 1
    else
        result n * factorial (n - 1)
    end if
end factorial
first_arr -> create (4, factorial)

proc print_table (x, i : int)
    put i, " | ", x
end print_table
first_arr -> each_with_index (print_table)


The next method is very special. It is the inject method. It is so special that wtd wrote an entire tutorial on it, entitled f. The function takes two parameters, a and b. Basically, inject starts with an initial value and takes the first element of the array, passing both of these into the function f. It stores the result of that function in its local variable. It then moves on to the second element of the array, passing it's local variable (which is f(starting_value, first_element)) and the second element to the function. This process is repeated until we reach the end of the array. The code might better illustrate this:


class IntArray
    export var value_at, create, inject
    var value_at : array 1 .. 1000 of int
    var n := 0
    proc create (num_of_elements : int, f : function f (x : int) : int)
        n := num_of_elements
        for i : 1 .. num_of_elements
            value_at (i) := f (i)
        end for
    end create
    function inject (start : int, f : function f (a, b : int) : int) : int
        var ans := start
        for i : 1 .. n
            ans := f (ans, value_at (i))
        end for
        result ans
    end inject
end IntArray

var first_arr : ^IntArray
new IntArray, first_arr

function factorial (n : int) : int
    if n < 2 then
        result 1
    else
        result n * factorial (n - 1)
    end if
end factorial
first_arr -> create (4, factorial)

function sum (a, b : int) : int
    result a + b
end sum
function maximum (a, b : int) : int
    if a > b then
        result a
    else
        result b
    end if
end maximum
put "The sum of the entries in first_arr is ", first_arr -> inject (0, sum)
put "The largest number in first_arr is ", first_arr -> inject (0, maximum)


Inject is a powerful method indeed, but it's power is limited by the functions we give it.

The next method I've made is the map method. map takes each element of our array and applies a function to it, returning a new array. It "maps" the function onto the array.

class IntArray
    export var value_at, create, map
    var value_at : array 1 .. 1000 of int
    var n := 0
    proc create (num_of_elements : int, f : function f (x : int) : int)
        n := num_of_elements
        for i : 1 .. num_of_elements
            value_at (i) := f (i)
        end for
    end create
    proc push (value : int)
        n += 1
        value_at (n) := value
    end push
    function map (f : function f (x : int) : int) : ^IntArray
        var new_arr : ^IntArray
        new IntArray, new_arr
        for i : 1 .. n
            new_arr -> push (f (value_at (i)))
        end for
        result new_arr
    end map
end IntArray

var first_arr : ^IntArray
new IntArray, first_arr

function factorial (n : int) : int
    if n < 2 then
        result 1
    else
        result n * factorial (n - 1)
    end if
end factorial
first_arr -> create (4, factorial)

function perfect_square (x : int) : int
    result x * x
end perfect_square
put "The squares of the first four factorials are: " ..
first_arr -> map (perfect_square) -> each (print)
put ""


The final method I've got is delete_if. This method takes one parameter: a function. This function takes one parameter: an integer. This function returns a boolean. The delete_if method will return a new array that is a duplicate of the current array, except all the elements of our current array who satisfy the function will be deleted. Here is the code:

class IntArray
    export var value_at, create, delete_if
    var value_at : array 1 .. 1000 of int
    var n := 0
    proc create (num_of_elements : int, f : function f (x : int) : int)
        n := num_of_elements
        for i : 1 .. num_of_elements
            value_at (i) := f (i)
        end for
    end create
    proc push (value : int)
        n += 1
        value_at (n) := value
    end push
    function delete_if (f : function f (x : int) : boolean) : ^IntArray
        var new_arr : ^IntArray
        new IntArray, new_arr
        for i : 1 .. n
            if f (value_at (i)) = false then
                new_arr -> push (value_at (i))
            end if
        end for
        result new_arr
    end delete_if
end IntArray

var first_arr : ^IntArray
new IntArray, first_arr

function factorial (n : int) : int
    if n < 2 then
        result 1
    else
        result n * factorial (n - 1)
    end if
end factorial
first_arr -> create (4, factorial)

proc print (x : int)
    put x, " " ..
end print
function even (x : int) : boolean
    result x mod 2 = 0
end even
put "The only elements of first_arr that even are: " ..
first_arr -> delete_if (even) -> each (print)
put ""


And that's all the methods I've reimplimented into Turing.


Conclusion

As you can see, this took a lot of code. Every time we wanted to call one of these extremely useful methods, we had to first define a function. This is very bothersome. After all these examples, I hope you can see why anonymous functions are so wonderful. They allow us to do all that we have done here, except much more elegantly. Compare the anonymous approach (using my own home-brewed Turing syntax),

first_arr -> delete_if (lambda {[x : int] x mod 2 = 0}) -> each (lambda {[x : int] put x, " " ..})

to the non-anonymous approach,

proc print (x : int)
    put x, " " ..
end print
function even (x : int) : boolean
    result x mod 2 = 0
end even
first_arr -> delete_if (even) -> each (print)



More Information

If you want, you can inject method (using it to find the sum of an array):



You can download the entire Turing IntArray class and the demonstration of it in the attached source file.

Feel free to ask questions.

-----------------------------------
Delos
Tue May 23, 2006 8:47 pm


-----------------------------------
/blown away

That was pretty damn sweet.  These concepts are utterly brilliant, and I can see why OOP is so bloody powerful.  Many a heartfelt thanks for taking the time to implement such code in Turing so that us uninitiates can learn a thing or two.

To that effect...you have an error!  Check out your delete_if method.  It pushes on false as opposed to true as your description says it should...

Anonymous fcns eh...interesting concept...

-----------------------------------
Cervantes
Tue May 23, 2006 9:12 pm


-----------------------------------

To that effect...you have an error!  Check out your delete_if method.  It pushes on false as opposed to true as your description says it should...

There is no error. ;)

It pushes on false. Only if the function returns false is that element pushed into the new array. Conversely, if the function returns true, that element is not pushed into the new array, and it is thus 'deleted' (though it still lives on in the current array).

If I had instead used a method like delete_at (index : int), then I would have called that whenever the given function f returned true.

Anyone have any suggestions for the next part? I could give the array of procedure example for a GUI widget, but that's kind of boring.

-----------------------------------
md
Tue May 23, 2006 9:58 pm


-----------------------------------
Cervantes... you scare me... turing as a functional language (sorta)? How do you even think of these things, let alone actually try?

'Course you can do all of these tricks in other languages too (C, C++, Pascal); though still without the anonymous functions.

-----------------------------------
wtd
Wed May 24, 2006 10:15 am


-----------------------------------
Cervantes... you scare me... turing as a functional language (sorta)? How do you even think of these things, let alone actually try?

'Course you can do all of these tricks in other languages too (C, C++, Pascal); though still without the anonymous functions.

You can't do anonymous functions in C++?  ;)

http://www.boost.org/doc/html/lambda.html

-----------------------------------
Cervantes
Wed May 24, 2006 11:23 am


-----------------------------------
Cervantes... you scare me... turing as a functional language (sorta)? How do you even think of these things, let alone actually try?

I was actually looking through the Turing Help Manual to help TheOneTrueGod out when I saw this very thing done. Look under 'paramDeclarations', or something like that (Well, not you, cornflake).

-----------------------------------
md
Wed May 24, 2006 12:27 pm


-----------------------------------
I see... and wtd thanks for pointing out that I'm wrong... now I get to play with more things (hopefully) :D

One place where function pointers are rather useful in graphics libraries is when you have a list of sprites. Each sprite might have all the same data in a record to control what and where to draw it, but they might all have different functions controlling how they move; or different collision functions. Instead of having to rely on the person using hte sprite library to call all the correct procedures you can just have two function pointers in your sprite record. One that's called every frame to move and update the sprite, and one that's called on collisions.

There was a sprite library for Pascal on Mac (actually _the_ library) that worked this way and it worked really well.

-----------------------------------
wtd
Wed May 24, 2006 4:54 pm


-----------------------------------
Once you realize the expressive power of fucntional programming, you begin to realize how short-sighted Turing is for using keywords for things like IO.

Imagine a world where "put" is a function.

some_int_array -> each (put)

But instead, we have to wrap put in a function.

-----------------------------------
GlobeTrotter
Wed May 24, 2006 7:30 pm


-----------------------------------
If "put" was a function, what would it return?  I understand get being a function.  Do you mean "put" as a procedure?

-----------------------------------
Delos
Wed May 24, 2006 7:40 pm


-----------------------------------
No, a function!  Think about it...imagine being able to do this:


foo_arr -> each (put ( root_with_base (3)));


On the fly output - this would be useful in debugging sits.  I'm sure wtd had more intricate thoughts in mind though, I'm just delving here ;).

-----------------------------------
wtd
Thu May 25, 2006 12:50 pm


-----------------------------------
No, a function!  Think about it...imagine being able to do this:


foo_arr -> each (put ( root_with_base (3)));


Without even realizing it, you have described partial function application.  It is one of the more powerful concepts in fucntional programming.  :)

-----------------------------------
MysticVegeta
Fri May 26, 2006 2:40 pm


-----------------------------------
For the area under a curve one we could use some integral calculus, simple 1 line function with no recursion.

function area (power : int, low, high : int) : real
    result ((high ** (power + 1)) / (power + 1)) - ((low ** (power + 1)) / (power + 1))
end area

put area (2, 0, 5)


-----------------------------------
zylum
Fri May 26, 2006 3:37 pm


-----------------------------------
your code will only work for functions of the form f(x) = x^power... the point is that you can pass any function to cervantes code and it will calculate the area. i'd imagine it would be quite difficult to implement code that finds the integral to any function (like here: http://integrals.wolfram.com/index.jsp)

-----------------------------------
Cervantes
Fri May 26, 2006 9:15 pm


-----------------------------------
Propogation of Functions: functions that return functions
(with imaginary Turing syntax)

What is a function? This is a question of a time long ago, when you were first learning the fundamentals of a function. You learned it is a block of code that takes some values as parameters and returns another value, or something like that.

Take this definition, but recall what I said in the opening of this tutorial.

functions in a functional language are first-class values, just like integers or strings

If a function is a first-class value, and if a function is just something that takes parameters and returns a value, then that value that it returns could itself be a function. In fewer words: A function that returns a function.


Function Composition

Here's an example. Say we have two functions, f(x) = x^2 and g(x) = x + 1. What is the value of f(g(x)) (also written as f&#805;&#805;&#805;&#805;&#8413;g, read as f composed with g)? Going through the math, it would be f(x + 1) = (x + 1)^2. Let's code this.
First, we'll define our functions

function f (x : real) : real
    result x ** 2
end f
function g (x : real) : real
    result x + 1
end g

Nothing new here. This is valid Turing syntax. However, this section is going to require us to pretend Turing can create anonymous functions, so we'll use the same syntax I introduced in part one. Let's redefine those functions, using this syntax:

var f : (function (x : real) : real) := lambda {[x : real] x ** 2}
var g : (function (x : real) : real) := lambda {[x : real] x + 1}

That's a pretty hefty data type, though. It's a lot to "type". Let's factor that out into a type (oh, oh, pun!):

type real2real : (function (x : real) : real)
var f : real2real := lambda {[x : real] x ** 2}
var g : real2real := lambda {[x : real] x + 1}

Now we must write a compose function:

function compose (f, g : real2real) : real2real
    var c : real2real := lambda {[x : real] f (g (x))}
    result c    % I defined the variable, 'c', just to specify the type of the function returned.
end compose

And put it to action:

var h : real2real := compose (f, g)
put h (5)       % outputs (5 + 1)^2 = 36

Function composition allows us to "compose" new functions from previously existing ones. This is a powerful concept, allowing us to code only the most basic functions, building the more advanced functions from them.


Partial Function Application

Once more, let's go back to our previous knowledge of functions. If I have a function f(a, b) = a + b, then calling f(5, 7) is acceptable, but calling f(5) is not. Why does calling f with only one parameter necessitate an error?

That's obvious, for sure. We can't return an integer if we are missing values to plug a + b. Fair enough: we can't return an integer. What can we return?

We can return a function. Since f(a, b) = a + b, f(5) = 5 + b. 5 + b is just another function. This is quite intuitive: if my function takes two parameters, then fixing one of them to a certain value returns another function that now only relies on one parameter.

Implementing PFA method one

Now, to implement this in Turing, we're not only going to have to use our "lambda" syntax for anonymous functions, we're going to have to use function overloading. In case you're not familiar with this concept, we'll take a very brief detour to explain it.

Detour: Function Overloading

Languages that support function overloading (languages such as my imaginary version of Turing) allow multiple copies of a function by the same name to exist, so long as they all take different parameters. When that function is called, the version of that function that is run is determined by the parameters passed in the function call. For example, if I have a function f(a, b) = a + b and another version of that function, f(a) = a + 5, then I can call f with either one or two parameters.


Using function overloading, here is an implementation of Partial Function Application on the function f in iTuring.

function f (a, b : int) : int
    result a + b
end f

function f (a : int) : (function (b : int) : int)
    result lambda {[b : int] a + b}
end f

Now we can call this function f like this:

put f (5, 7)      % => 12
put (f (5)) (7)   % => 12

The second represents f (5) creating a new function that takes 7 as a parameter and returns 5 + 7 = 12.

There's another way we can implement PFA, however; one that does not require function overloading.


Implementing PFA method two

This approach involves our function f returning a function that returns a function...

var f : ((function (a : int) : (function (b : int) : int))) := lambda {[a : int] lambda {[b : int] a + b}}

Calling f now looks like this:

put (f (5)) (7) % => 12



What's the point?

There is no point to Partial Function Application if we're just going to use it like (f (5)) (7). We might as well just write f (5, 7). So what's the point?

Partial Function Application, just like Function Composition, allows us to quickly and easily create new functions from a base of functions. Say we had a function to multiply two numbers,

var mul := lambda {[a, b : int] a * b}

We could then, using PFA, create functions with names based on the English language:

var double := mul (2)
var triple := mul (3)
% ...


We could also pass the function returned by our PFA technique into another function. Assuming we've got an already initialized IntArray object based on my IntArray class from the TURuby section of this tutorial, the following code doubles each element in our array.

int_array -> map (mul (2))

No need to go through all the 'lambda' business. This one is actually readable, too: "map 'multiply by 2' onto int_array".



-----------------------------------
wtd
Sat May 27, 2006 5:41 pm


-----------------------------------
Good stuff.  I would mention that this works much better in languages where it's actually meant to happen.  :)

-----------------------------------
MysticVegeta
Mon May 29, 2006 1:25 pm


-----------------------------------
wait a sec, if this is all imaginary syntax, then what you are trying to do by writing this tut? Are you sending something to holtsoft to implement these features or is it jsut for beginners to functional programming like me understand this concept, but not be able to do this turing?

-----------------------------------
Delos
Mon May 29, 2006 1:32 pm


-----------------------------------
wait a sec, if this is all imaginary syntax, then what you are trying to do by writing this tut? Are you sending something to holtsoft to implement these features or is it jsut for beginners to functional programming like me understand this concept, but not be able to do this turing?

Essentially the latter.  There's nothing wrong or outlandish about presenting a theoretical tutorial.  If people are able to follow along with it, then it might just be time for them to embrace another language to implement such structures.
Personally, I find that having these conceptually challenging ideas thrown around quite conducive to my own coding.  The more I read about functional programming, the more I use it (even if it still is in Turing).  Getting into good habits, methinks...

-----------------------------------
wtd
Mon May 29, 2006 2:10 pm


-----------------------------------
A lot of it is fictional in Turing.  But it's not imaginary elsewhere.

Cervantes' lambda syntax is imaginary.  I know, I helped devise it.  :)

But, there are lots of languages where this can be done.

Common Lisp:

(let ((foo (lambda (bar) (+ (* bar 2) 1))))
   (funcall foo 4))

Scheme:

(let ((foo (lambda (bar) (+ (* bar 2) 1))))
   (foo 4))

Haskell:

let foo = \bar -> bar * 2 + 1 in foo 4

Or using composition:

let foo = (+ 1) . (* 2) in foo 4

O'Caml:

let foo = fun bar -> bar * 2 + 1 in
   foo 4

SML:

let 
   val foo = fn bar => bar * 2 + 1
in
   foo 4
end

Python:

foo = lambda bar: bar * 2 + 1
foo(4)

Ruby:

foo = lambda { |bar| bar * 2 + 1 }
foo.call(4)

Smalltalk:

| foo |
   foo := [ :bar | bar * 2 + 1 ].
   foo value: 4

Io:

foo := block(bar, bar * 2 + 1)
foo(4)

Scala:

val foo = bar: Int => bar * 2 + 1
foo(4)

C# 3.0:

var foo = bar => bar * 2 + 1;
foo(4);

Nice:

let Any->Any foo = Any bar => bar * 2 + 1;
foo(4);

I likely left out a huge number of languages.

-----------------------------------
Delos
Mon May 29, 2006 4:42 pm


-----------------------------------
Bah, polyglot...

-----------------------------------
Cervantes
Mon May 29, 2006 5:22 pm


-----------------------------------
Nice, wtd! As wtd's post clearly shows, the idea of anonymous functions is a big deal. It's a big deal because it relieves the heavy burden of declaring a function before using it for it's one time purpose, as illustrated by the TURuby section.

wait a sec, if this is all imaginary syntax, then what you are trying to do by writing this tut? Are you sending something to holtsoft to implement these features or is it jsut for beginners to functional programming like me understand this concept, but not be able to do this turing?
As Delos said, the latter. This tutorial serves as a segue to higher level languages. The concepts discussed in this tutorial (and in the full [url=http://www.compsci.ca/v2/viewtopic.php?t=10904]OOP tutorial) are very applicable to programming languages, though less so to Turing. Thus, these tutorials begin the journey into new programming paradigms from within the comfortable world of Turing, thereby making the transition to new languages easier.

-----------------------------------
kishan25
Tue Jan 13, 2009 5:38 pm

RE:Turing as a Functional Programming Language
-----------------------------------
this was really helpful to me

-----------------------------------
syntax_error
Tue Jan 13, 2009 5:50 pm

Re: RE:Turing as a Functional Programming Language
-----------------------------------
this was really helpful to me

necroposting is bad.

-----------------------------------
redsp0t
Sun Nov 14, 2010 10:16 pm

RE:Turing as a Functional Programming Language
-----------------------------------
Amazing guide, really helpful like all of your other guides.
