Discord
Login
Community
DARK THEME

max() and similar functions problem

how use functions ( max(), min(), ... ) with array ? example: max([0,6,5]) --> 6

init = function()
  arr = [ 0, 6, 5 ]
  local  m =  arr.reduce( function( accumulator, currentValue )
   return max( accumulator, currentValue )
  end)
  print( m )
end

MicroScript2 has access to basic types and their methods from JavaScript. For example, the Array class has basic methods named "forEach" , "reduce" , "slice" . You can refer to these methods although they are not listed in the official MicroScript2 documentation. They will run as fast as Javascript runs.

https://microstudio.dev/community/tips/undocumented-functions/558/

thanks

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community