minimum spanning tree lua HPPL
|
11-05-2021, 10:10 PM
Post: #17
|
|||
|
|||
RE: minimum spanning tree lua HPPL
It seems XCas already has "safe" extend built-in, called semi-augment
semi_augment(A,B) := when(len(A)!=len(B), extend(A,B), extend(append(A,head(B)),tail(B))) Cas> semi_augment([[1,2],[3,6],[6,10]] , [[2,1],[6,3],[10,6]]) [[1,2], [3,6], [6,10], [2,1], [6,3], [10,6]] // 3+3 = 6 items Cas> semi_augment([[1,2]] , [[3,4,5]]) [[1,2], [3,4,5]] // 1 + 1 = 2 items Had we use extend instead, we get these: Cas> extend([[1,2],[3,6],[6,10]] , [[2,1],[6,3],[10,6]]) [[1,2,2,1], [3,6,6,3], [6,10,10,6]] Cas> extend([[1,2]] , [[3,4,5]]) [[1,2,3,4,5]] |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)