Language-Integrated Query (Linq)

Language-Integrated Query (Linq) - Useful functions for working with sets. - 消息

#1 已发布: 2014/4/24 23:03:35
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

Language-Integrated Query (Linq).

Useful functions for working with sets.

Functions list:

`if(2), `if(3), select(2), select2(2), selectmany(2), join(5), where(2), where2(2), aggregate(2), aggregate(3), take(2), takewhile(2), takewhile2(2), skip(2), first(2), repeat(2), any(2), all(2), contains(2), count(2), batch(2), batch(3), exclude(3), takeevery(2).


Links:

1. LINQ - Language-Integrated Query.
2. morelink - Extensions to LINQ to Objects (jonathan.skeet, ...).
Linq. Examples.sm (37.48 KiB)已下载 1355 次。
Russia ☭ forever, Viacheslav N. Mezentsev
5位用户喜欢此帖子
Serg 2016/8/29 10:47:00, Martin Kraska 2014/4/25 02:52:00, Davide Carpi 2014/4/25 04:47:00, Mike Kaganski 2014/4/25 08:03:00, Radovan Omorjan 2014/4/25 01:28:00
#2 已发布: 2014/4/25 02:59:17
Martin Kraska

Martin Kraska

1,362个赞,共2,276个帖子。

组: Moderator

Uni, the way you provide arguments to your functions looks interesting. How is it expected to work, does it really what it should? What are the formal restrictions? This is not even known for ordinary function arguments, thus I wonder how thin the ice is that you are on ;-)
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#3 已发布: 2014/4/25 03:42:57
Radovan Omorjan

Radovan Omorjan

325个赞和1个踩,共2,052个帖子。

组: Moderator

I totally forgot that this is possible in SMath

[MATH=eng]f(x,`):`(x)^2[/MATH]

[MATH=eng]f(x:6,`(x):x)=36[/MATH]

[MATH=eng]f(y:7,`(x):x+1)=64[/MATH]

Uni used quite unusual character for a function name (`).

I forgot this as well (making a function argument call by value)


[MATH=eng]f(x):line(x:9,x^2,2,1)[/MATH]

[MATH=eng]a:100[/MATH]
[MATH=eng]f(a)=81[/MATH]
[MATH=eng]a=9[/MATH]

Contrary to


[MATH=eng]b:100[/MATH]
[MATH=eng]f(b:b)=81[/MATH]
[MATH=eng]b=100[/MATH]

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#4 已发布: 2014/4/25 04:59:06
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: Moderator

Very nice functions Viacheslav

I think that also contains() should contains a break to maximize the performances.


Wrote

I totally forgot that this is possible in SMath


Sometimes happens :d
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1位用户喜欢此帖子
#5 已发布: 2014/4/25 05:25:22
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

LINQ - Language-Integrated Query.

`(...) := (...) - lambda expression. This is an imitation of an implicit function in SMath Studio.

I wrote it for fun. But in this way you can check out the features of the program. I think this will SMath Studio future.
You can add here your own versions of these functions.

The ice is very thin, but it works I used this technique when solving the ODEs (D(t,x):=...). With regard to the restrictions, I do not see them for now.
These functions should work as vector functions, hiding the use of cycles.
Russia ☭ forever, Viacheslav N. Mezentsev
1位用户喜欢此帖子
Davide Carpi 2014/4/25 09:42:00
#6 已发布: 2014/4/25 06:30:30
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

Updated. Small improvements.

P.S. Here, the aggregate function is implemented not correctly.
2014-04-25 17-15-58 SMath Studio Desktop - [Linq.sm].png
Russia ☭ forever, Viacheslav N. Mezentsev
1位用户喜欢此帖子
Mike Kaganski 2014/4/25 08:16:00
#7 已发布: 2014/4/25 08:17:32
Mike Kaganski

Mike Kaganski

184个赞,共434个帖子。

组: User

I have a feature request: please allow MULTIPLE thanks to uni! (Well, on second thought, I'm afraid I could break my left muse button then...)
С уважением, Михаил Каганский
2位用户喜欢此帖子
Davide Carpi 2014/4/25 13:00:00, Вячеслав Мезенцев 2014/4/25 08:50:00
#8 已发布: 2014/4/25 08:58:34
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

Updated. aggregate() - fixed.
2014-04-25 18-57-10 SMath Studio Desktop - [Linq.sm].png
Russia ☭ forever, Viacheslav N. Mezentsev
1位用户喜欢此帖子
Davide Carpi 2014/4/25 09:42:00
#9 已发布: 2014/4/25 11:34:29
Ryan Freund

Ryan Freund

20个赞,共339个帖子。

组: User

I'm not sure if it is worth your time to explain but what is this?
Why is it beneficial?
Sorry for my ignorance.
#10 已发布: 2014/4/25 12:27:11
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

It's not so easy for me to explain what is it for. I must implement basic functions, then it will be possible to show by examples why it maybe useful.
Moreover, it is quite complicated examples. With their help, you can test the Smath Studio.
Russia ☭ forever, Viacheslav N. Mezentsev
1位用户喜欢此帖子
Davide Carpi 2014/4/25 13:00:00
#11 已发布: 2014/4/25 12:52:33
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: Moderator

Wrote

I'm not sure if it is worth your time to explain but what is this?
Why is it beneficial?
Sorry for my ignorance.



LINQ is for C# a write less/do more extension (like jQuery for javascript); in a short expression there are lot of basic instructions.

here you can found a good overview of LINQ; because was born to handle in a better way databases in C# (even if today is like a programming language itself), it's a good project also to use it with SMath's matrices (a database in the end is only a matrix with types fixed for each column)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#12 已发布: 2014/4/25 17:49:29
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

Updated.

Unfortunatelly, nested queries not supported.
2014-04-26 03-47-40 SMath Studio Desktop - [Linq. Plot.sm].png
Russia ☭ forever, Viacheslav N. Mezentsev
2位用户喜欢此帖子
Davide Carpi 2014/4/25 18:24:00, Radovan Omorjan 2014/4/26 02:42:00
#13 已发布: 2014/4/25 18:57:58
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

Plot example.

Linq. Plot.png
Linq. Plot.sm (7.04 KiB)已下载 1315 次。
Russia ☭ forever, Viacheslav N. Mezentsev
2位用户喜欢此帖子
Radovan Omorjan 2014/4/26 02:42:00, Davide Carpi 2014/4/25 21:10:00
#14 已发布: 2014/4/25 19:22:45
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

selectmany example.

Linq. selectmany.png
Linq. selectmany.sm (7 KiB)已下载 1287 次。
Russia ☭ forever, Viacheslav N. Mezentsev
1位用户喜欢此帖子
Davide Carpi 2014/4/25 21:10:00
#15 已发布: 2014/4/25 20:43:19
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

ODE plot.

Linq. ODE plot.png
Linq. ODE plot.sm (10.3 KiB)已下载 1330 次。
Russia ☭ forever, Viacheslav N. Mezentsev
2位用户喜欢此帖子
Radovan Omorjan 2014/4/26 02:43:00, Davide Carpi 2014/4/25 21:10:00
#16 已发布: 2014/4/26 08:24:15
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

Updated. join(5) added.
Linq. join.sm (8.66 KiB)已下载 1328 次。
Russia ☭ forever, Viacheslav N. Mezentsev
#17 已发布: 2014/4/26 12:00:06
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

Updated. batch(2), batch(3) added.
Linq. batch.sm (9.34 KiB)已下载 1332 次。
Russia ☭ forever, Viacheslav N. Mezentsev
1位用户喜欢此帖子
Davide Carpi 2014/4/26 12:29:00
#18 已发布: 2014/4/27 12:47:38
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: Moderator

An high-productively hint to anyone that want to use this useful extension but (like me) does not have a keyboard with the backtick/backquote (grave accent) symbol:

1. Download the AutoHotKey free tool (full-installation or portable, both for 32 and 64 bit machines) (link)
2. Unzip and launch the script attached here (with the portable app you can drag the file over the executable)


This script enable the following shortcuts:
- hold down the Windows Key and press ' to produce the backtick `
- hold down the Windows Key and press numbers to produce numpad numbers (this is useful on notebook w/o numpad)


Best regards,

Davide


P.S. the script can be customized to change the keys combinations and can be launched automatically on windows startup.

edit: the 2nd attachment "shortcuts_exe.zip" is a portable executable compiled from the script that enable the features described above without downloading the tool and the script.
shortcuts_exe.zip (793.65 KiB)已下载 453 次。
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#19 已发布: 2014/4/28 05:16:52
Вячеслав Мезенцев

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

1,558个赞,共1,868个帖子。

组: Moderator

MC15 works much faster.
Mathcad - Linq.pdf (70.04 KiB)已下载 828 次。
Russia ☭ forever, Viacheslav N. Mezentsev
#20 已发布: 2014/4/29 09:59:54
kilele

kilele

134个赞,共397个帖子。

组: User

Hi, I've seen the autohotkey script shared by Davide in this thread and thought that this .ahk might be of interest for someone, place the mouse over the screen top to bring it up. You can add other symbols by editing the script.
charsbar.zip (1.39 KiB)已下载 442 次。
  • 有新帖
  • 无新帖