Centroid of a set of N-dimensional points: Difference between revisions
Content added Content deleted
(Added C) |
(→{{header|Raku}}: Added Raku solution) |
||
Line 190: | Line 190: | ||
</pre> |
</pre> |
||
[[File:Plot centroid.png|center|thumb]] |
[[File:Plot centroid.png|center|thumb]] |
||
=={{header|Raku}}== |
|||
<syntaxhighlight lang="raku" line>sub centroid { ( [»+«] @^LoL ) »/» +@^LoL } |
|||
say .¢roid for |
|||
( (1,), (2,), (3,) ), |
|||
( (8, 2), (0, 0) ), |
|||
( (5, 5, 0), (10, 10, 0) ), |
|||
( (1, 3.1, 6.5), (-2, -5, 3.4), (-7, -4, 9), (2, 0, 3) ), |
|||
( (0, 0, 0, 0, 1), (0, 0, 0, 1, 0), (0, 0, 1, 0, 0), (0, 1, 0, 0, 0) ), |
|||
; |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre>(2) |
|||
(4 1) |
|||
(7.5 7.5 0) |
|||
(-1.5 -1.475 5.475) |
|||
(0 0.25 0.25 0.25 0.25)</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |