0 Members and 3 Guests are viewing this topic.
In other news, Frey continues kicking unprecedented levels of ass.
Map(λ(r12),L1,100)
Well, as someone who uses them all the time in programming, I can say they are very useful in many situations. They can help reduce the number of methods needed to evaluate a certain value. DeepThought gives a decent example with different features per level, such as if you had two different levels of gravity:Code: [Select]@gravity = lambda {|cur_level|(cur_level%5==0)?(1):(2)} / air_densitySo that every five levels the lambda would return 2 instead of 1. In that example you could take out the lambda and still be fine, but there are even bigger needs for it when you need to directly pass values as parameters into complex equations with highly varying outputs or when you go to attach them to variables directly so that a variable's state is defined by input parameters. Which brings me to ask, quigibo: are you thinking of adding full support for lambdas/procs with variable attachments and inlining functions, or just inlining?EDIT: hmm, so the case here isn't just that many don't know how to use them, but that they also don't know what they are understandable. In a nutshell:Lambdas are functions that stand in for single values (though in some cases they can return multiple values, but don't worry about that most languages don't even support it). They can take passed arguments and can contain code that'll evaluate expressions and return values accordingly. Very, very useful. For a decent background, here's the wikipedia link Qwerty pointed me to a long time ago that I found very helpful: http://en.wikipedia.org/wiki/Lambda_calculus
@gravity = lambda {|cur_level|(cur_level%5==0)?(1):(2)} / air_density
Quote from: Quigibo on July 08, 2011, 02:43:17 pmMap(λ(r12),L1,100)I have couple remarks on that First of all, since we will presumably be able to make routines such as Map( ourselves, could you show us the syntax for calling a subroutine by address? (Something like sub(r1, ...)r, perhaps? (Where r1 is any expression))Secondly, will inlining be supported? (In general, not just for Map() That is, if an anonymous subroutine (or lambda, whatever you want to call them) is passed to a routine and that routine has a call for it exactly once, will the compiler replace the call with the routine itself? Otherwise, your example, among other useful invocations, will be much slower than it should be.
You guys already know how awesome you are, you don't need me to tell you that