Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: OT: Mathematics for programming (again)

by Jenda (Abbot)
on Sep 11, 2008 at 10:27 UTC ( [id://710576]=note: print w/replies, xml ) Need Help??


in reply to Re^2: OT: Mathematics for programming (again)
in thread OT: Mathematics for programming (again)

Equivalent to looping, I buy that. But equivalent_to_X ne X.

The fact that I can move and use legs for that doesn't mean that since a car can move as well it's got to have legs.

  • Comment on Re^3: OT: Mathematics for programming (again)

Replies are listed 'Best First'.
Re^4: OT: Mathematics for programming (again)
by mr_mischief (Monsignor) on Sep 11, 2008 at 15:37 UTC
    More specifically, any language that has goto, conditional jumps, or continuations can be used to implement loops if they don't have native loops. Any language which can build and walk a tree or list can be used to implement a loop, too. Any language in which one can attach arbitrary actions to an iterator has a basic looping construct. Any language that can both increment or decrement an integer value and evaluate data as code can be used to implement loops.

    Things equivalent to loops in one situation or another include recursion, vector operators, iterators, and repetition operators. Tail recursion or mutual recursion between two subroutines can be converted into a looping construct. Vector operators are made up of loops unless they are using special explicitly parallel hardware. Iterators can both be the basis of a loop and can be implemented using a loop or some loop equivalent. Repetition operators are usually implemented as loops, but could be implemented using recursion, conditional jumps, lists, set manipulations, vector ops, or continuations. Any language in which you can construct, transform, and test arbitrary sets in arbitrary ways can be used as an equivalent to loops, too.

    SQL is a declarative set specification and transformation language. Where the loops in SQL are is obvious if you look at the issue sideways: they are implicit. SELECT, UPDATE, and DELETE are vector operators and WHERE confines the members of the vector to some subset of the master set. INSERT is a vector operator which adds to the master set. Each SQL statement (barring special functions) is a subset specification, set growth or shrinkage operation, or transformation on (sub)set members. There generally is an iterative or recursive program in charge of getting you the proper results for your requested set. You're just not writing it. It's the product of translation and happens inside the database software's planning and execution engines. Still, since SQL can store, transform, and test arbitrary sets in arbitrary ways, it can be used equivalently to a language with explicit loops in regards to those sets.

Re^4: OT: Mathematics for programming (again)
by Anonymous Monk on Sep 12, 2008 at 20:09 UTC

    That's a bit backwards: HOW it gets there is unimportant. That it can accomplish the task eventually is what really matters.

    If the Car and the Person were both Touring [sic] complete, and it is known that the Person can Tour France (using feet) then the implication is that the Car can Tour France as well. How it accomplishes that (with wheels) and how long it takes is unimportant. It can simulate the Human's route and make the Tour because it is, by definition, Touring complete.

    • Making a Tour = Loops
    • Touring France = Looping over all elements in a list of cities
    • Using Feet = "for" statement
    • Using Wheels = "JMP" statement

      You did not leave von Neumann there. Not "for" and "JMP", but rather "for" and "recursion". And recursion in a language that doesn't have mutable variables. And

      • Making a Tour = implementing an algorithm
      • Touring France = creating the program
      • Using Feet = using loops
      • Using Wheels = using recursion

      The thing is not whether it's possible to implement the same algorithms, but whether reasoning about the individual building blocks of one kind of programming languages will be useful for other kinds.

      With your "for" vs "JMP" you've stayed within the von Neumann architecture, there are languages that are built on , say, lambda calculus. And even though both are turing complete and may be used to implement the same algorithms and eventualy transform the same data to the same result, their building blocks are different.

        Their building blocks may be different, but if your Turing complete language does not include a for loop, you can write code that will simulate a for loop. It may not be efficient, and it may not be core, but you can do it.

        If you can implement a system which analyzes one such language, you can inefficiently port it to other languages by simulating those other languages in your first language.
        This may, however, fall afoul of your "useful" clause in terms of practicality regarding CPU and memory use.

        Equivalent to looping, I buy that. But equivalent_to_X ne X.
        The difference is in terminology and syntax (and efficiency of implementation), but those do not change the essential nature of looping.
        It is more of an: ("X" ne "X/2 + X^0 + 0.5 * X - 1") and (X == (X/2 + X^0 + 0.5 * X - 1))
        Where the LHS is Looping, and the RHS is equivalent to looping in a language without core loop support.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://710576]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-16 07:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found