POV-Ray : Newsgroups : povray.off-topic : Wikipath Server Time
1 Oct 2024 03:17:30 EDT (-0400)
  Wikipath (Message 31 to 40 of 47)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 7 Messages >>>
From: Orchid XP v8
Subject: Re: Wikipath
Date: 15 Aug 2008 14:58:25
Message: <48a5d1d1$1@news.povray.org>
>> you suddenly realise that you'd like to use the number on the top of 
>> the stack as the *denominator*, not the numerator, or something like 
>> that. 
> 
> I think there's a button for *that* case, actually.

Division and subtraction are the obvious ones. (Oh, and exponent if 
there's a button for that.)

Thinking about it, a button to swap the top two operands ought to fix 
most problems you might have.

I also anticipate that being able to somehow "inspect" the stack might 
come in handy if you can't remember what you put on there already...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: Wikipath
Date: 15 Aug 2008 15:11:18
Message: <48a5d4d6$1@news.povray.org>
Orchid XP v8 wrote:
> Thinking about it, a button to swap the top two operands ought to fix 
> most problems you might have.

That's kind of what I was referring to, yes.

> I also anticipate that being able to somehow "inspect" the stack might 
> come in handy if you can't remember what you put on there already...

Yes. I expect such a thing might have been around on some of the 
calculators I remember seeing.

-- 
Darren New / San Diego, CA, USA (PST)


Post a reply to this message

From: Joel Yliluoma
Subject: Re: Wikipath
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

From: Invisible
Subject: Re: Wikipath
Date: 1 Sep 2008 07:32:22
Message: <48bbd2c6$1@news.povray.org>
Joel Yliluoma wrote:

> 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);
>   }
> 
> 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

Haskell [is that cheating??]

   value = (\x -> 3*x + 5) 42

Lambda calculus:

   \i ->
   (\n -> \m -> \f -> \x -> n f (m f x))
   (
     (\n -> \m -> \f -> \x -> n (m f) x)
     (\f -> \x -> f (f (f x)))
     i
   )
   (\f -> \x -> f (f (f (f (f x)))))

[I can't be bothered to write "42" in the lambda calculus. Suffice it to 
say it contains 42 copies of the letter "f".]

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Wikipath
Date: 1 Sep 2008 16:27:10
Message: <48bc501e@news.povray.org>
Joel Yliluoma wrote:
> C++0x:
>   
>   int main()
>   {
>     int value = <>(int x) (3*x+5) (42);
>   }

I thought it was [], not <>.

But I don't have any C++0x compiler...


Post a reply to this message

From: Warp
Subject: Re: Wikipath
Date: 1 Sep 2008 17:38:38
Message: <48bc60de@news.povray.org>
Nicolas Alvarez <nic### [at] gmailcom> wrote:
> Joel Yliluoma wrote:
> > C++0x:
> >   
> >   int main()
> >   {
> >     int value = <>(int x) (3*x+5) (42);
> >   }

> I thought it was [], not <>.

  I suppose the exact syntax has still not been written to stone. The
current wikipedia article on the subject uses your syntax:

http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions

-- 
                                                          - Warp


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Wikipath
Date: 1 Sep 2008 17:41:52
Message: <48bc619f@news.povray.org>
Warp wrote:
>   I suppose the exact syntax has still not been written to stone. The
> current wikipedia article on the subject uses your syntax:
> 
> http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions
> 

It's not a feature I'm likely to use much, anyway. I'm more interested in
the range-based for loop (yes, I know it's pure syntax sugar), and template
concepts.

Currently:
for (std::vector<int>::iterator i = myList.begin(); i != myList.end(); ++i)

With the new type determination feature:
for (auto i = myList.begin(); i != myList.end(); ++i)

With the range-based for loop:
for (int &x : myList)

<3


Post a reply to this message

From: Warp
Subject: Re: Wikipath
Date: 2 Sep 2008 08:44:21
Message: <48bd3525@news.povray.org>
Nicolas Alvarez <nic### [at] gmailcom> wrote:
> It's not a feature I'm likely to use much, anyway.

  Lambda function will make it much easier to use STL algorithms which take
a user-defined functor (such as for example for_each(), find_if(),
transform(), etc.) which will make them much more desirable. They will
also make it easier to quickly create data containers with more exotic
comparison functions than less_than or greater_than.

> I'm more interested in
> the range-based for loop (yes, I know it's pure syntax sugar), and template
> concepts.

  Personally I'm drooling over rvalue references, which will allow for much
more efficient move semantics.

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: Wikipath
Date: 2 Sep 2008 15:13:42
Message: <48bd9066$1@news.povray.org>
Warp wrote:
>   Personally I'm drooling over rvalue references, which will allow for much
> more efficient move semantics.

My understanding is that informally, this lets you match a template or 
overload where one or more of the arguments is, essentially, guaranteed 
to not be aliased.  Is this a reasonable summary?

-- 
Darren New / San Diego, CA, USA (PST)


Post a reply to this message

From: Fredrik Eriksson
Subject: Re: Wikipath
Date: 2 Sep 2008 16:18:13
Message: <op.ugveonda7bxctx@e6600>
On Tue, 02 Sep 2008 21:13:43 +0200, Darren New <dne### [at] sanrrcom> wrote:
> Warp wrote:
>>   Personally I'm drooling over rvalue references, which will allow for  
>> much more efficient move semantics.
>
> My understanding is that informally, this lets you match a template or  
> overload where one or more of the arguments is, essentially, guaranteed  
> to not be aliased.  Is this a reasonable summary?


Not really, at least not the way I understand it.

R-value references are basically just a way to bind temporaries to  
non-const references. Specifically, they facilitate move constructors  
which are much like copy constructors except that they may destructively  
alter the source of the "copy".


-- 
FE


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 7 Messages >>>

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