You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to glowscri...@googlegroups.com
Hello there!
I am working in Glowscript VPython 2.4. According to help documentations, arange() gives you an ordered sequence (list) of numbers. So I tried this:
#######################################
GlowScript 2.4 VPython
x = arange(-5,5,10/50)
label(text="Max of x: "+max(x))
#######################################
But it doesn't work. What is the problem? Also I tried access the value of x[0] (which I guess is -5) but no success, it returns Undefined.
Thank you.
Bruce Sherwood
unread,
Apr 1, 2017, 9:45:18 PM4/1/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Glowscript Users
Interesting. I had not realized that
A = range(3,15,2)
print(A)
gives this result:
{start:3, step:2, stop:15}
Clearly RapydScript-NG in transpiling Python to JavaScript generates a dictionary that is used in for loops but which does not provide list-type access to individual elements. There is no mention of this limitation in the RapydScript-NG documentation, so I'll ask about this.
For the moment the only workaround is to do this:
A = []
for i in range(3,15,2):
A.append(i)
This will work in both GlowScript VPython and Jupyter VPython.
Bruce Sherwood
unread,
Apr 2, 2017, 6:20:07 AM4/2/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Glowscript Users
I reported the issue to the developer of RapydScript-NG, and he has already responded by implementing handling range like a list when appropriate. Kovid Goyal is amazingly responsive. I have some work to do to upgrade to his latest version.
Sebastian Silva
unread,
Apr 2, 2017, 9:02:19 PM4/2/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to glowscri...@googlegroups.com
El 01/04/17 a las 20:45, Bruce Sherwood escribió:
Hi Bruce et all,
This works for me:
A = list(range(3,15,2))
print(A)
[3, 5, 7, 9, 11, 13]
It works in cpython and rapydscript-ng.
Hope it helps,
Regards,
Sebastian
Bruce Sherwood
unread,
Apr 2, 2017, 9:10:16 PM4/2/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Glowscript Users
You're right, that's another possible work-around.
Incidentally, it's interesting in CPython to do this:
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Glowscript Users
I upgraded the RapydScript-NG transpiler in GlowScript, and now with r = range(5,7), r[1] is 6.
However, I was surprised that max([5,3,2,13]) gives "undefined" despite the fact that the RS-NG doc says that lists have almost all the functionality of regular Python lists. I've asked about this.
Bruce Sherwood
unread,
Apr 3, 2017, 10:47:20 AM4/3/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Glowscript Users
And again Kovid Goyal responded immediately, so min and max methods applied to lists (and to range) are now available.
Bill Nettles
unread,
Nov 18, 2020, 2:15:48 PM11/18/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Glowscript Users
x=arange(0.3,pi,0.1)
returns a list of length 5. If one changes the 0.1 step to something else, the length is still 5. x is a list of length 5 no matter what I do with the arange() function in Glowscript VPython
Bruce Sherwood
unread,
Nov 18, 2020, 4:38:52 PM11/18/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Glowscript Users
You're right, that's a bug in RapydScript-NG. I've reported it. Thanks.
Bruce
Bruce Sherwood
unread,
Nov 19, 2020, 1:20:46 PM11/19/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Glowscript Users
As is so often the case, Kovid Goyal, the lead developer of RapydScript-NG (and of Calibre, a widely used program for converting from one ebook format to another), fixed the range bug just a few hours after I reported it. GlowScript has been updated using his fix.
Bruce
Bill Nettles
unread,
Nov 19, 2020, 2:31:26 PM11/19/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message