LibreLogo - Error in Help for RANGE?

classic Classic list List threaded Threaded
6 messages Options
Kolbjørn Stuestøl Kolbjørn Stuestøl
Reply | Threaded
Open this post in threaded view
|

LibreLogo - Error in Help for RANGE?

Continuing experimenting with LibreLogo.

Help for LibreLogo says that:

PRINT RANGE 3 10 3 ; print [3, 6, 9] (i.e. outputs 3, 6, 9.)

When I try it I get the output: "range (3 10 3)".
(Also "LABEL RANGE 3 10 3" and "TEXT RANGE 3 10 3" outputs "range (3 10
3)".)

I do not know Python programming. Is this the way Python handles lists?
Help call this a Python-like list generation.

I expected that "PRINT RANGE 0 10 2" will output every second item in
the range: 0, 2, 4, 6, 8.

On the other hand, the function
FOR :n IN RANGE 10 101 5 [
     FORWARD :n LEFT 90
]
works as expected.

Am I misunderstanding the Help for RANGE or is the Help incorrect?

Hoping I am not the only one playing with LibreLogo :-)

Kolbjørn

--
To unsubscribe e-mail to: [hidden email]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

libreoffice-ml.mbourne libreoffice-ml.mbourne
Reply | Threaded
Open this post in threaded view
|

Re: LibreLogo - Error in Help for RANGE?

Kolbjørn Stuestøl wrote:

> Continuing experimenting with LibreLogo.
>
> Help for LibreLogo says that:
>
> PRINT RANGE 3 10 3 ; print [3, 6, 9] (i.e. outputs 3, 6, 9.)
>
> When I try it I get the output: "range (3 10 3)".
> (Also "LABEL RANGE 3 10 3" and "TEXT RANGE 3 10 3" outputs "range (3 10
> 3)".)
>
> I do not know Python programming. Is this the way Python handles lists?
> Help call this a Python-like list generation.

It looks like the LibreLogo code is translated into Python code, and
what you're seeing is a change between Python 2.7 and Python 3. In
Python 2.7, range() returns a list of values, which would display as [3,
6, 9]. In Python 3, range() returns an iterable object, which will
return each value in turn as you iterate over it (it doesn't actually
create a list of all the values, so is more efficient for large ranges).

> I expected that "PRINT RANGE 0 10 2" will output every second item in
> the range: 0, 2, 4, 6, 8.

In Python, you should be able to get a list by using:
   list(range(0, 10, 2))
I'm not sure how that would be done in Logo though; perhaps:
   LIST RANGE 0 10 2
following the syntax you've shown in other examples.

> On the other hand, the function
> FOR :n IN RANGE 10 101 5 [
>      FORWARD :n LEFT 90
> ]
> works as expected.

The "for" loop iterates over the iterator returned by range(), so
executes the loop for each number which would have been in the list.

> Am I misunderstanding the Help for RANGE or is the Help incorrect?

Perhaps the help is out of date, or perhaps it depends which version of
Python you have. I don't know whether LibreLogo includes a Python
interpreter or uses one you install separately.

> Hoping I am not the only one playing with LibreLogo :-)
>
> Kolbjørn


--
To unsubscribe e-mail to: [hidden email]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Kolbjørn Stuestøl Kolbjørn Stuestøl
Reply | Threaded
Open this post in threaded view
|

Re: LibreLogo - Error in Help for RANGE?

Den 10.12.2015 23:27, [hidden email] skreiv:

> Kolbjørn Stuestøl wrote:
>> Continuing experimenting with LibreLogo.
>>
>> Help for LibreLogo says that:
>>
>> PRINT RANGE 3 10 3 ; print [3, 6, 9] (i.e. outputs 3, 6, 9.)
>>
>> When I try it I get the output: "range (3 10 3)".
>> (Also "LABEL RANGE 3 10 3" and "TEXT RANGE 3 10 3" outputs "range (3 10
>> 3)".)
>>
>> I do not know Python programming. Is this the way Python handles lists?
>> Help call this a Python-like list generation.
>
> It looks like the LibreLogo code is translated into Python code, and
> what you're seeing is a change between Python 2.7 and Python 3. In
> Python 2.7, range() returns a list of values, which would display as
> [3, 6, 9]. In Python 3, range() returns an iterable object, which will
> return each value in turn as you iterate over it (it doesn't actually
> create a list of all the values, so is more efficient for large ranges).
This means that the three PRINT examples must/should be rewritten.
To get the expected result I have to print out a list of the items
created by AREA:
PRINT = LIST AREA 0 10 2
which prints "[0, 2, 4, 6, 8]" as expected.

>
>> I expected that "PRINT RANGE 0 10 2" will output every second item in
>> the range: 0, 2, 4, 6, 8.
>
> In Python, you should be able to get a list by using:
>   list(range(0, 10, 2))
> I'm not sure how that would be done in Logo though; perhaps:
>   LIST RANGE 0 10 2
> following the syntax you've shown in other examples.
Yes. As you see above.

>
>
>> On the other hand, the function
>> FOR :n IN RANGE 10 101 5 [
>>      FORWARD :n LEFT 90
>> ]
>> works as expected.
>
> The "for" loop iterates over the iterator returned by range(), so
> executes the loop for each number which would have been in the list.
Yes.
>
>> Am I misunderstanding the Help for RANGE or is the Help incorrect?
>
> Perhaps the help is out of date, or perhaps it depends which version
> of Python you have. I don't know whether LibreLogo includes a Python
> interpreter or uses one you install separately.
Whatever the reason, I think the help should be rewritten. As a
translator I am able to rewrite the help in Norwegian but have no access
to change the original text.

If LibreLogo use Python, it is included in the full installation. I have
not installed it separately.

Thank you for your help.
Kolbjørn
>
>
>> Hoping I am not the only one playing with LibreLogo :-)
>>
>> Kolbjørn
>
>


--
To unsubscribe e-mail to: [hidden email]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
libreoffice-ml.mbourne libreoffice-ml.mbourne
Reply | Threaded
Open this post in threaded view
|

Re: LibreLogo - Error in Help for RANGE?

Kolbjørn Stuestøl wrote:

> Den 10.12.2015 23:27, [hidden email] skreiv:
>> Kolbjørn Stuestøl wrote:
>>> Continuing experimenting with LibreLogo.
>>>
>>> Help for LibreLogo says that:
>>>
>>> PRINT RANGE 3 10 3 ; print [3, 6, 9] (i.e. outputs 3, 6, 9.)
>>>
>>> When I try it I get the output: "range (3 10 3)".
>>> (Also "LABEL RANGE 3 10 3" and "TEXT RANGE 3 10 3" outputs "range (3 10
>>> 3)".)

...

>>> Am I misunderstanding the Help for RANGE or is the Help incorrect?
>>
>> Perhaps the help is out of date, or perhaps it depends which version
>> of Python you have. I don't know whether LibreLogo includes a Python
>> interpreter or uses one you install separately.
> Whatever the reason, I think the help should be rewritten. As a
> translator I am able to rewrite the help in Norwegian but have no access
> to change the original text.
>
> If LibreLogo use Python, it is included in the full installation. I have
> not installed it separately.

I agree the help does seem to be out of date. I'd suggest filing a bug
report against the "Documentation" component of LibreOffice at
<https://bugs.documentfoundation.org/> (after checking that it's not
already reported).

Mark.


--
To unsubscribe e-mail to: [hidden email]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Kolbjørn Stuestøl Kolbjørn Stuestøl
Reply | Threaded
Open this post in threaded view
|

Re: LibreLogo - Error in Help for RANGE?

Den 11.12.2015 21:38, [hidden email] skreiv:

> Kolbjørn Stuestøl wrote:
>> Den 10.12.2015 23:27, [hidden email] skreiv:
>>> Kolbjørn Stuestøl wrote:
>>>> Continuing experimenting with LibreLogo.
>>>>
>>>> Help for LibreLogo says that:
>>>>
>>>> PRINT RANGE 3 10 3 ; print [3, 6, 9] (i.e. outputs 3, 6, 9.)
>>>>
>>>> When I try it I get the output: "range (3 10 3)".
>>>> (Also "LABEL RANGE 3 10 3" and "TEXT RANGE 3 10 3" outputs "range
>>>> (3 10
>>>> 3)".)
>
> ...
>
>>>> Am I misunderstanding the Help for RANGE or is the Help incorrect?
>>>
>>> Perhaps the help is out of date, or perhaps it depends which version
>>> of Python you have. I don't know whether LibreLogo includes a Python
>>> interpreter or uses one you install separately.
>> Whatever the reason, I think the help should be rewritten. As a
>> translator I am able to rewrite the help in Norwegian but have no access
>> to change the original text.
>>
>> If LibreLogo use Python, it is included in the full installation. I have
>> not installed it separately.
>
> I agree the help does seem to be out of date. I'd suggest filing a bug
> report against the "Documentation" component of LibreOffice at
> <https://bugs.documentfoundation.org/> (after checking that it's not
> already reported).
>
> Mark.
Not found any reports on this error.
I will file a bug report with some suggestions, but have to wait until
another day. Sometimes I have other things to do :-)
Kolbjørn
>
>



--
To unsubscribe e-mail to: [hidden email]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Kolbjørn Stuestøl Kolbjørn Stuestøl
Reply | Threaded
Open this post in threaded view
|

Re: LibreLogo - Error in Help for RANGE?

Den 11.12.2015 22:49, Kolbjørn Stuestøl skreiv:

> Den 11.12.2015 21:38, [hidden email] skreiv:
>> Kolbjørn Stuestøl wrote:
>>> Den 10.12.2015 23:27, [hidden email] skreiv:
>>>> Kolbjørn Stuestøl wrote:
>>>>> Continuing experimenting with LibreLogo.
>>>>>
>>>>> Help for LibreLogo says that:
>>>>>
>>>>> PRINT RANGE 3 10 3 ; print [3, 6, 9] (i.e. outputs 3, 6, 9.)
>>>>>
>>>>> When I try it I get the output: "range (3 10 3)".
>>>>> (Also "LABEL RANGE 3 10 3" and "TEXT RANGE 3 10 3" outputs "range
>>>>> (3 10
>>>>> 3)".)
>>
>> ...
>>
>> I agree the help does seem to be out of date. I'd suggest filing a
>> bug report against the "Documentation" component of LibreOffice at
>> <https://bugs.documentfoundation.org/> (after checking that it's not
>> already reported).
>>
>> Mark.
> Not found any reports on this error.
> I will file a bug report with some suggestions, but have to wait until
> another day. Sometimes I have other things to do :-)
> Kolbjørn
*Bug 96446* <https://bugs.documentfoundation.org/show_bug.cgi?id=96446>
Kolbjørn


--
To unsubscribe e-mail to: [hidden email]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted