Variable equals itself plus something else

閲覧: 155 回
最初の未読メッセージにスキップ

Ste Wilson

未読、
2019/10/28 13:49:082019/10/28
To: TiddlyWiki
I've found some simple ish basic programs in an old text book... Hmm thought I.. They could be use full.. Can I tiddlywiki them (because of course, everything should be tiddlywikyable)... So...

While I understand what's going on here for example..

110 INPUT P, A
120 IF P= 0 AND A=0 THEN GOTO 180
130 A=R*A
140 H=H+P*COS(A)
150 V=V+P*SIN(A)
160 PRINT "NEXT KNOWN FORCE: "
170 GOTO 110

My initial thought was I could do that.. Maybe with mathcell.. But then I got to lines 130, 140 and 150...can I do that in wikitext with fields?

Ste

Mark S.

未読、
2019/10/28 14:23:372019/10/28
To: TiddlyWiki
Yipes! Spaghetti code!

You can add a variable to itself as long as you keep nesting:

<$set name="s" value="5">
<$set name="s" filter="[<s>add{!!addme}]">
<<s>>
</$set>
</$set>

What's actually happening is each "set" is creating its own name space.

For more complicated scenarios you might be able to use recursion.

There is no sine or cosine functionality AFAIK in TW.

Ste Wilson

未読、
2019/10/28 14:42:202019/10/28
To: TiddlyWiki
Thanks mark, I'll have a play. The mathcell macro allows js math operations so I can use that for the trig.. I think..

Mark S.

未読、
2019/10/28 15:43:232019/10/28
To: TiddlyWiki
There's an approximation formula that could be made in TW:

sine(x) =x-(x^3)/6+(x^5)/120

But, the thing is, the full power of Javascript math is so close ... without the need for approximations. Well, I suppose
all values of sine (except special cases) are approximations.

Ste Wilson

未読、
2019/10/28 17:45:152019/10/28
To: TiddlyWiki
Think I'll just go learn a bit of js instead...
to get the number to use the set widget on is actually the first hurdle because the value in the field is the formula and the mathcell macro (allows access to js math) uses the reveal widget to give the result, and I can't work out how to wikify it, even though i'm fairly sure this is a problem I've solved/ had solved for me before (cant' find the solution anywhere!),only THEN can i get recursive :D

Thanks for the help Mark!

TonyM

未読、
2019/10/28 19:49:302019/10/28
To: tiddl...@googlegroups.com
Ste, [minor edits]

Of course you could use Evans formulas plugin for more advanced math. 

I  was an advanced basic coder from way back. The problem is basic is a procedural language, in your question, part of computing the result is to call subroutines/gotos etc.. This is not the way its done in tiddlywiki, although you can have transclusions operating similarly. If instead you can take your basic code back to pseudocode I think you will find it easier to then find the tools in tiddlywiki to do the job. For example marks formulae, once you write the "problem" as Tsine(x) =x-(x^3)/6+(x^5)/120 this should be able to be put in evans formula plugin in his cute mushroom brackets (= formulae =) including references to fields and variables.

Although I would love to be better versed in Javascript inclusion in tiddlywiki, my opinion is that you would find value in learning how to implement such solutions in tiddlywiki rather than reverting to javascript, this would be investing in your own development in understanding tiddlywiki, increased reusability over bespoke java script, and much more shareable solutions. Basically move into native tiddlywiki plus generalised plugins. 

Once you have mastered native tiddlywiki you may discover some gaps (Not so many remain) which you could remedy with a general solution in javascript you can share with the community and advance tiddlywiki further. 

Regards
Tony

@TiddlyTweeter

未読、
2019/10/29 1:59:342019/10/29
To: TiddlyWiki
Hi Steve

Not sure you'd know but on GG on Android phone for some reason your avi morphs from being normal into a large mad professor! Lol.

TT

photo_2019-10-29_06-55-29.jpg


TonyM

未読、
2019/10/29 2:27:342019/10/29
To: TiddlyWiki
Yes,  large mad professor

It's dam scary :)

Tony

Ste Wilson

未読、
2019/10/29 3:05:042019/10/29
To: TiddlyWiki
I did not know that. It is quite terrifying!

Ste Wilson

未読、
2019/10/30 17:11:312019/10/30
To: TiddlyWiki
Tony, you were correct. Tiddlywiki is the way and Evans formula plug in is a thing of beauty.

https://tmcengineering.updog.co/Simple%20Frame%20Calc.html

I think it gets the correct answer.... :D

Cheers

Ste

Ste Wilson

未読、
2019/10/30 17:13:422019/10/30
To: TiddlyWiki
Ps.. If anyone knows how or why the round command is giving answers like 10.260000000006 instead of 10.26 that would be helpful!

Diego Mesa

未読、
2019/10/30 17:33:492019/10/30
To: TiddlyWiki
Hey Ste,

You're using 0.1.1 of Evans plugin. The latest available on his website is 0.2.3:

Ste Wilson

未読、
2019/10/31 17:04:092019/10/31
To: TiddlyWiki
Hi Diego,
Update has made no difference :( but thanks for pointing it out.

As google has kindly tagged the site a phishing site (it dosn't seem to like tiddly wiki with updog on dropbox, though only seems to get pounced on after I post a link here...maybe not do that again...)
I'll post a new thread and attach the Calculator of Angles Using the Method of Joints for Simple Frames as a tid/ json file just in case someone ever needs it :)

Diego Mesa

未読、
2019/10/31 18:37:322019/10/31
To: TiddlyWiki
Hey Ste,

When I exported your two tiddlers as JSON and uploaded to a local copy of Evans, the round worked as expected for me

Ste Wilson

未読、
2019/10/31 18:53:332019/10/31
To: TiddlyWiki
Hmmmm.. How odd.. I shall double check

TonyM

未読、
2019/10/31 19:31:572019/10/31
To: TiddlyWiki
Ste,

Rounding errors are common especially where you are using division or multiplying decimal numbers. Evans plugin includes rounding functions. You could just reduce the number of places in the output. eg to 10.26000000

Regards
Tony

Ste Wilson

未読、
2019/11/02 9:55:082019/11/02
To: TiddlyWiki

TonyM

未読、
2019/11/02 23:35:202019/11/02
To: TiddlyWiki
Ste,

Demonstrates the possibility of very complex calculations. Good work.

tony
全員に返信
投稿者に返信
転送
新着メール 0 件