Anthrazit

770 Reputation

11 Badges

5 years, 23 days

MaplePrimes Activity


These are questions asked by Anthrazit

Any idea why parse("a", 'statement') doesn't return the value of the variable, but only its name?

Running the same command directly works.

Download ParseStatement.mw

I've got a problem where I need to find the shortest route between a list of points. Each point must only be visited once.

To solve the problem I admit that I have used ChatGPT. While the answer was very helpful, the thing is that it apparently doesn't work (yet). The problem is that the function in the package is not existing.

Here's the ChatGPT code.

Any help appreciated.

euclidean_distance := proc (p1, p2) options operator, arrow; sqrt((p1[1]-p2[1])^2+(p1[2]-p2[2])^2) end proc; points := [[0, 0], [1, 2], [3, 1], [5, 4]]; distance_matrix := Matrix([`$`([`$`(euclidean_distance(points[i], points[j]), i = 1 .. 4)], j = 1 .. 4)]); solution := Optimization:-LinearSumAssignment(distance_matrix); optimal_route := [`$`(points[i], `in`(i, solution[1]))]; total_distance := add(`$`(distance_matrix[i, solution[1][i]], `in`(i, solution[1]))); print("Optimal route:", optimal_route); print("Total distance:", total_distance)

"Total distance:", total_distance

(1)

NULL

Download TravellingSalesManChatGPT.mw

What's the correct command to return the number of elements in this command? It returns an expression sequence, but I didn't manage to get anything useful in return.

StringTools:-SearchAll("aba", "abababababababababab")

Is it possible to split a table (not the datatype, but the insert - table one)?

Something happens when I redefine an indexed value of a table, but I'm not sure what.

Here's the situation before the definition.

eval(WhateverYouNeed["calculations"]["structure"]["connection"]);


TABLE(["Cutright1" = "false", "graindirection1" = 90 Unit(arcdeg), "Cutleft2" = "false",  "lengthleft2" = 500 Unit(mm), "Cutrightsteel" = "false", "lengthleftsteel" = "false", "lengthleft1" = 350 Unit(mm), "lengthright2" = 500 Unit(mm), "connection_1" = "Timber", "lengthrightsteel" = "false", "connection_2" = "Timber", "Cutleft1" = "false", "Cutleftsteel" = "false", "graindirection2" = 0, "graindirectionsteel" = "false", "Cutright2" = "false", "lengthright1" = 150 Unit(mm), "connection_InsideLayers" = 1])

I then try to redefine one specific entry of the table.
WhateverYouNeed["calculations"]["structure"]["connection"]["connection_1"] := GetProperty("ComboBox_connection_1", 'value');

WhateverYouNeed["calculations"]["structure"]["connection"]["connection_1"] := "Timber"

Which gives this new result.

eval(WhateverYouNeed["calculations"]["structure"]["connection"]);


TABLE(["connection_1" = "Timber"])

The rest of the indices and entries of the "connection" table is gone.

1 2 3 4 5 6 7 Last Page 2 of 25