division operator and regular expressions

View: New views
8 Messages — Rating Filter:   Alert me  

division operator and regular expressions

by doc_brown :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello, everybody!

First let me thank the creator and developers of the Boo for fantastic
job. I am a research scientist, not a software developer and after
just a couple of weeks I found Boo ideally suited to my needs
(friendly python-like syntax, interactive interpreter, possibility to
work with .Net numerical and plotting libraries, serial ports,
databases etc.)

I have a couple of questions:

1. It looks like the division operator '/' messes with regular
expression marks '/.../' . If I use the division operator in a long
math equation more then once, the compiler does not understand that
and generates an error. How can I avoid this situation? (except for
using 'b*a**(-1)' instead of 'b/a' which makes the code less readable)

2. When I run the same code for numerical integration (around 20
million operations in one loop) as compiled and  as interpreted, the
execution speed is practically same (7.5 s). Does it mean that Boo
interpreter compiles the loops during execution?

Thank you very much for your response.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: division operator and regular expressions

by Cedric Vivier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hey doc!

On Wed, Jun 25, 2008 at 11:04 PM, doc_brown <vm_tch@...> wrote:
> 1. It looks like the division operator '/' messes with regular
> expression marks '/.../' . If I use the division operator in a long
> math equation more then once, the compiler does not understand that
> and generates an error. How can I avoid this situation? (except for
> using 'b*a**(-1)' instead of 'b/a' which makes the code less readable)

Ugh, not friendly yeah.
Hopefully surrounding the whole math expression by parenthesis should
do the trick.
ie. x = (a / b / c / d)


> 2. When I run the same code for numerical integration (around 20
> million operations in one loop) as compiled and  as interpreted, the
> execution speed is practically same (7.5 s). Does it mean that Boo
> interpreter compiles the loops during execution?

Yeah it is compiled to the same code (thus same performance).
You would have a performance hit only when using duck-typing.


Regards,

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: division operator and regular expressions

by doc_brown :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thank you, Cedric,
I tried different (see below) combinations, but it did not work...
I will think more about this...

As for the JIT compilation, it is great! The same code runs 7.5
minutes on Octave !

Cheers,

doc_brown

>>> x=4.0
4
>>> y=5.0
5
>>> a=1.0
1
>>> b=3.0
3
>>> x/y+a/b
----------^
ERROR: Unexpected token: b.
>>> (x/y+a/b)
------^
ERROR: Unexpected token: /y+a/.
-----------^
ERROR: Unexpected token: b.
>>> (x/y)+(a/b)
------^
ERROR: Unexpected token: /y)+(a/.
-------------^
ERROR: Unexpected token: b.
>>> x/y/a/b
--------^
ERROR: Unexpected token: a.
>>> (x/y/a)/b
------^
ERROR: Unexpected token: /y/.
---------^
ERROR: Unexpected token: a.
>>> z=(x/y/a/b)
--------^
ERROR: Unexpected token: /y/.
-----------^
ERROR: Unexpected token: a.
-------------^
ERROR: Unexpected token: b.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: division operator and regular expressions

by James Gregory-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try surrounding the division operator in spaces, that works for me.

>>>x / y + a / b

Works for me, it's not as concise, but at least it compiles!

On Wed, Jun 25, 2008 at 4:37 PM, doc_brown <vm_tch@...> wrote:

Thank you, Cedric,
I tried different (see below) combinations, but it did not work...
I will think more about this...

As for the JIT compilation, it is great! The same code runs 7.5
minutes on Octave !

Cheers,

doc_brown

>>> x=4.0
4
>>> y=5.0
5
>>> a=1.0
1
>>> b=3.0
3
>>> x/y+a/b
----------^
ERROR: Unexpected token: b.
>>> (x/y+a/b)
------^
ERROR: Unexpected token: /y+a/.
-----------^
ERROR: Unexpected token: b.
>>> (x/y)+(a/b)
------^
ERROR: Unexpected token: /y)+(a/.
-------------^
ERROR: Unexpected token: b.
>>> x/y/a/b
--------^
ERROR: Unexpected token: a.
>>> (x/y/a)/b
------^
ERROR: Unexpected token: /y/.
---------^
ERROR: Unexpected token: a.
>>> z=(x/y/a/b)
--------^
ERROR: Unexpected token: /y/.
-----------^
ERROR: Unexpected token: a.
-------------^
ERROR: Unexpected token: b.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: division operator and regular expressions

by Georges Benatti Junior :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

That's a problem that i have pointe to Bamboo more then once since Boo
was created.
The provisory solution is to put spaces between the operations, like:
z = x / y / a / b

Hope it helps,

On Wed, Jun 25, 2008 at 12:37 PM, doc_brown <vm_tch@...> wrote:

>
> Thank you, Cedric,
> I tried different (see below) combinations, but it did not work...
> I will think more about this...
>
> As for the JIT compilation, it is great! The same code runs 7.5
> minutes on Octave !
>
> Cheers,
>
> doc_brown
>
>>>> x=4.0
> 4
>>>> y=5.0
> 5
>>>> a=1.0
> 1
>>>> b=3.0
> 3
>>>> x/y+a/b
> ----------^
> ERROR: Unexpected token: b.
>>>> (x/y+a/b)
> ------^
> ERROR: Unexpected token: /y+a/.
> -----------^
> ERROR: Unexpected token: b.
>>>> (x/y)+(a/b)
> ------^
> ERROR: Unexpected token: /y)+(a/.
> -------------^
> ERROR: Unexpected token: b.
>>>> x/y/a/b
> --------^
> ERROR: Unexpected token: a.
>>>> (x/y/a)/b
> ------^
> ERROR: Unexpected token: /y/.
> ---------^
> ERROR: Unexpected token: a.
>>>> z=(x/y/a/b)
> --------^
> ERROR: Unexpected token: /y/.
> -----------^
> ERROR: Unexpected token: a.
> -------------^
> ERROR: Unexpected token: b.
> >
>



--
Georges "The Firewalker"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: division operator and regular expressions

by doc_brown :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Wow, thanks a lot, James!

Now it works. The genius solutions are always the simplest ones ;)

Cheers,

doc_brown

On Jun 25, 11:42 am, "James Gregory" <jagregory....@...> wrote:
> Try surrounding the division operator in spaces, that works for me.
>
> >>>x / y + a / b
>
> Works for me, it's not as concise, but at least it compiles!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: division operator and regular expressions

by doc_brown :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thank you all again, guys
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: division operator and regular expressions

by Rodrigo B. de Oliveira :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Wed, Jun 25, 2008 at 12:49 PM, Georges Benatti Junior
<gbenatti@...> wrote:
>
> That's a problem that i have pointe to Bamboo more then once since Boo
> was created.

Indeed you have.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price