データの整列
Posted feedbacks - Erlang
既存が無かったので、書いてみました。
使いかたは
L1 = [{1,8}, {3,4}, {1,3}, {2,4}, {1,2}].
sort:lexical(L1).
sort:fromOrigin(L1).
な感じです。
1 2 3 4 5 6 7 8 | -module(sort).
-export([lexical/1, fromOrigin/1]).
lexical(L) ->
lists:sort(L).
fromOrigin(L) ->
lists:sort(fun ({AA,AB},{BA,BB}) -> (AA*AA + AB*AB) < (BA*BA + BB*BB) end, L).
|


odz #5839() Rating1/1=1.00
(x, y) の座標情報を以下の2種類の方法で整列する機能を実現してください。
データの表現方法はタプルなり構造体/オブジェクトなり各自で適当に選んで下さい。
[ reply ]