POV-Ray : Newsgroups : povray.off-topic : Wikipath : Re: Wikipath Server Time
1 Oct 2024 03:13:53 EDT (-0400)
  Re: Wikipath  
From: Joel Yliluoma
Date: 1 Sep 2008 07:12:05
Message: <48bbce05$1@news.povray.org>
On Fri, 15 Aug 2008 08:58:35 +0100, Invisible wrote:
> Nicolas Alvarez wrote:
>
>> JavaScript functions don't need names.
>> 
>> var value = (function (x) {
>>     return 3*x + 5;
>> })(42);
>> 
>> That actually works.
>
> Ooo... that's interesting.

Python:

  value = (lambda(x): 3*x+5)(42)

Lua:

  value = (function(x) return 3*x+5 end)(42)

Ruby (1):

  def test
    yield 42
  end
  value = test { |x| 3*x+5 }

Ruby (2):

  value = lambda { |x| 3*x+5 } .call(42)

C++0x:
  
  int main()
  {
    int value = <>(int x) (3*x+5) (42);
  }

  (I would have tested this, but the build instructions
   at http://parasol.tamu.edu/groups/pttlgroup/lambda/
   don't work for me, tried to computers...)

i386 assembly (ok, this is cheating):
  mov eax, 42
  call over
  lea eax, [eax*2+eax+5]
  ret
over:
  pop eax
  call eax
  mov [value], eax

-- 
Joel Yliluoma - http://iki.fi/bisqwit/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.