String to Variable Name (str2var)

String to Variable Name (str2var) - Сообщения

#1 Опубликовано: 31.12.2022 02:33:45
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Is there a function or method that would allow a string (or variable name) located in a matrix element to be used as the name to define a variable?

Something like this:

Str2Var.png

Thank you!
#2 Опубликовано: 31.12.2022 04:28:45
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 сообщений из 1708 понравились пользователям.

Группа: Moderator

Файл не найден. Файл не найден.

str2num_full.png
Russia ☭ forever, Viacheslav N. Mezentsev
4 пользователям понравился этот пост
Mark R Harris 31.12.2022 06:43:00, NDTM Amarasekera 31.12.2022 10:10:00, overlord 01.01.2023 15:20:00, sergio 31.12.2022 08:09:00
#3 Опубликовано: 31.12.2022 06:43:07
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Thank you so much uni!
#4 Опубликовано: 01.01.2023 12:51:50
Laurent Fournier

Laurent Fournier

9 сообщений из 66 понравились пользователям.

Группа: User

WOW!!!
#5 Опубликовано: 02.01.2023 06:31:00
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: Moderator

Wrote

Is there a function or method that would allow a string (or variable name) located in a matrix element to be used as the name to define a variable?



You can also use the Assign() function of the Maxima Plugin (this should work even without Maxima installed).

It converts boolean equations into assignments.

In the case of strings you still need to apply str2num()

Assign.sm (4 КиБ) скачан 47 раз(а).
assign.PNG
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
2 пользователям понравился этот пост
sergio 02.01.2023 07:35:00, Mark R Harris 02.01.2023 17:02:00
#6 Опубликовано: 04.01.2023 20:02:47
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Some odd behavior here. When the "=" evaluation is removed the Assign() function breaks:

Assign odd behaviour.png
Assign odd behaviour.sm (3 КиБ) скачан 33 раз(а).

Any thoughts?

I'm hoping to be able to assign multiple variables from a matrix like this:
Assign For Loop.png
Assign For Loop Broken.sm (5 КиБ) скачан 43 раз(а).
#7 Опубликовано: 04.01.2023 21:47:22
churichuro

churichuro

28 сообщений из 79 понравились пользователям.

Группа: User

a small workaround, could be to place the for inside a line command and return a false token value, it is not very clean but it works as far as I can see.



I think the assign command is not evaluated immediately, but has a delayed evaluation, which somehow only takes place after using the "=" symbol.
1 пользователям понравился этот пост
Mark R Harris 04.01.2023 22:04:00
#8 Опубликовано: 05.01.2023 11:30:01
overlord

overlord

554 сообщений из 1333 понравились пользователям.

Группа: Moderator

Wrote

You can also use the Assign() function of the Maxima Plugin (this should work even without Maxima installed).


Assign() is a useful function and it doesn't need Maxima as you have indicated.
I don't (can't) use Maxima but I need Assign() sometimes.
And its codes have zero relation with Maxima functions.

This is why I suggested sometime ago that it could have relocated in another collective plugin.
CustomFunctions plugin is a good candidate for this purpose.
But I am not persistence, it is what it is.
Author of these plugins choose it this way.

Regards
1 пользователям понравился этот пост
Mark R Harris 05.01.2023 18:24:00
#9 Опубликовано: 05.01.2023 16:57:04
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: Moderator

Wrote

Some odd behavior here. When the "=" evaluation is removed the Assign() function breaks:

Assign odd behaviour.png
Assign odd behaviour.sm (3 КиБ) скачан 33 раз(а).

Any thoughts?

I'm hoping to be able to assign multiple variables from a matrix like this:
Assign For Loop.png
Assign For Loop Broken.sm (5 КиБ) скачан 43 раз(а).



Two hints:

- The Assign function needs to be executed in order to do it's work, either by assigning the result to some dummy variable or by requesting display of the result.
- You don't need a loop, Assign() can handle vector arguments

Blatt10.png
Blatt10.sm (5 КиБ) скачан 42 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 пользователям понравился этот пост
Mark R Harris 05.01.2023 18:24:00
#10 Опубликовано: 05.01.2023 17:22:41
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: Moderator

Wrote

Wrote

You can also use the Assign() function of the Maxima Plugin (this should work even without Maxima installed).


Assign() is a useful function and it doesn't need Maxima as you have indicated.
I don't (can't) use Maxima but I need Assign() sometimes.
And its codes have zero relation with Maxima functions.

This is why I suggested sometime ago that it could have relocated in another collective plugin.
CustomFunctions plugin is a good candidate for this purpose.
But I am not persistence, it is what it is.
Author of these plugins choose it this way.

Regards



In general I don't care where Assign() is defined. It is in the Maxima plugin, because I needed a neat way to make use of results from Maxima functions like algebraic or ode solvers.

Yet I don't think that it would be a good idea to remove functions from plugins, because this would break the dependency management of existing sheets.

I don't know what happens if the same function is defined in multiple plugins. Would SMath crash? If not, which definition is used if both plugins are installed? One would see this in the dynamic help, but how to control?

BTW, I think that some day I'll revisit the Maxima plugin and if I get some help with a linux development tool chain and work flow I could perhaps make the plugin work also under linux. But that would require at least two months of full time work without distractions, because I would need to learn C# anew from scratch.

If someone is a master in C# I am happy to assist in refactoring and bug fixing of the plugin by providing the specifications and unit tests.

I'd be more comfortable with python or javascript but to my knowledge these aren't options for making plugins.
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 пользователям понравился этот пост
Mark R Harris 05.01.2023 18:25:00
#11 Опубликовано: 06.01.2023 02:15:05
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1675 понравились пользователям.

Группа: User

Hi. This could be another option.

Clipboard01.png

MyAssign 2.sm (10 КиБ) скачан 48 раз(а).

Best regards.
Alvaro.
7 пользователям понравился этот пост
⚜ Kenny Lemens, P.E. ᵂᴵ 27.02.2023 12:19:00, Вячеслав Мезенцев 06.01.2023 07:07:00, NDTM Amarasekera 06.01.2023 12:57:00, sergio 06.01.2023 14:23:00, churichuro 06.01.2023 16:19:00, bdrunagle 06.01.2023 16:21:00, Mark R Harris 06.01.2023 16:41:00
#12 Опубликовано: 06.01.2023 16:25:18
churichuro

churichuro

28 сообщений из 79 понравились пользователям.

Группа: User

@Razonar, as usual with you, you give imaginative and useful solutions, it's great when people share their knowledge and help others, and with such a high technical level. thanks and congratulations.

I have a folder on my computer exclusively for the spreadsheets you share.
2 пользователям понравился этот пост
Mark R Harris 06.01.2023 17:15:00, Alvaro Diaz Falconi 06.01.2023 23:10:00
#13 Опубликовано: 06.01.2023 16:42:15
Arie

Arie

93 сообщений из 285 понравились пользователям.

Группа: User

In the event you may want to add descriptions to these definitions... a related thread:
https://en.smath.com/forum/yaf_postst23228_Assign-Description-to-Variable.aspx

It's a work around, but potentially useful.
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
3 пользователям понравился этот пост
Alvaro Diaz Falconi 06.01.2023 23:10:00, sergio 07.01.2023 07:09:00, Mark R Harris 06.01.2023 16:50:00
#14 Опубликовано: 06.01.2023 16:43:00
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Wrote

@Razonar, as usual with you, you give imaginative and useful solutions, it's great when people share their knowledge and help others, and with such a high technical level. thanks and congratulations.

I have a folder on my computer exclusively for the spreadsheets you share.



Yes indeed. Likewise. What churichuro said!
1 пользователям понравился этот пост
Alvaro Diaz Falconi 06.01.2023 23:10:00
#15 Опубликовано: 06.01.2023 23:11:34
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1675 понравились пользователям.

Группа: User

Thanks guys. I sincerely appreciate that.

Best regards.
Alvaro.
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений