Using max's default argument in Glowscript?

14 views
Skip to first unread message

11 Irishjs

unread,
Aug 17, 2022, 7:46:25 AM8/17/22
to Glowscript Users
I am wondering if it is possible to implement the default argument for Python's max function? A simple case is outlined below:


my_list = []

print(max(my_list, default=5))



The above fails in Glowscript with the message that default is a reserved word.
Or maybe there is another way around this issue?

Thanks,
Patrick

Bruce Sherwood

unread,
Aug 17, 2022, 1:06:10 PM8/17/22
to Glowscript Users
Fixing that looks quite difficult. There certainly is a way around this:

def mymax(L, D):
    if len(L) == 0: return D
    return(max(L))

a = []
print(mymax(a,5))

Bruce

11 Irishjs

unread,
Aug 17, 2022, 1:07:41 PM8/17/22
to glowscri...@googlegroups.com
Ok, sure. I guess I could just do that. 
Thanks

--

---
You received this message because you are subscribed to a topic in the Google Groups "Glowscript Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/glowscript-users/DZIogX0zavo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to glowscript-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glowscript-users/CA%2BWuaSdSjZ_g2T44y6g35Q7rJOBCxPknEJFP3M%3DYjHe3HrnLgg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages