POV-Ray : Newsgroups : povray.off-topic : Wikipath Server Time
1 Oct 2024 00:05:02 EDT (-0400)
  Wikipath (Message 28 to 37 of 47)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Darren New
Subject: Re: Wikipath
Date: 15 Aug 2008 11:48:53
Message: <48a5a565$1@news.povray.org>
Invisible wrote:
> (I've never tried this extensively, but I would suggest that it probably 
> requires a little forethought before you start the calculation...)

Not too much. If you have the equation written down, the rule is that 
you type in the numbers in the order they appear, and you type in the 
operators as soon as you've gotten all the arguments for that operator.

Now, if it's not written down, it can take some head-twisting, but IME 
not any more than using infix. Certainly easier than using infix without 
parentheses built into the calcualtor.

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


Post a reply to this message

From: Orchid XP v8
Subject: Re: Wikipath
Date: 15 Aug 2008 13:42:55
Message: <48a5c01f$1@news.povray.org>
>> (I've never tried this extensively, but I would suggest that it 
>> probably requires a little forethought before you start the 
>> calculation...)
> 
> Not too much. If you have the equation written down...

I was thinking more if you're just casually throwing numbers around, and 
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. 
If you know before hand exactly what computation you want to perform 
then yes it's quite easy.

-- 
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 13:49:03
Message: <48a5c18f$1@news.povray.org>
Orchid XP v8 wrote:
> 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.

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


Post a reply to this message

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

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

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