Equivalent of an array of objects

G’day,

This may not be of any use to you, but I could not help but think of this, so I bring it up in case it can trigger helpful ideas for your efforts.

I’m a big believer that even the silliest of things, even if totally useless, can suddenly bring a light bulb moment (a great idea that seemingly has nothing at all in common with the silliest of things…)

Use Case for Session Storage: Fibonacci Series

Warning: yeah, I did unashamedly use some javascript for this. And I hope I never see, in my lifetime, TiddlyWiki core features added to handle this without javascript.

:smile:

I hope my joking tone about that came through. I appreciate everything people have been offering, and while I think I’ll probably set aside the attempt I was making, I am going to go through everything people have offered. Some of it offers clean-up or just alternate means of doing the same thing, good to know. But much of it looks to teach me a lot.

Yes, it is an interesting alternative. It’s not useful for my current project, where I want the resulting (read-only) wiki to be as familiar to navigate as possible for users. But I want it to have the wonderful cross-linking, and composition features of TW for users, and its editing facility for myself (and eventually other writers). Unless the users already know TW, they won’t even know that the site is implemented in it. Such users would likely see Tag Pills as merely decorative.

This is for me a large wiki. I expect at the end that I’ll have about 250 “pages”, tiddlers linked from the TOC, with 40,000 - 50,000 words of text, 50+ screenshots, and 200 code samples, consisting of perhaps 700 - 800 total tiddlers, many of them transcluded into multiple pages. I’m trying to take seriously Divio’s documentation breakdown, and as well as Reference, How-tos, and Explanations, I also have a handful of Tutorials of 5 - 10 pages each. It’s those, and those only, that will get this navigation treatment. Everything else will conform to TW’s non-linear philosophy. I will probably extract the shell of it to use for other documentation projects, both for work and for personal projects.

While I’m very happy with how it’s coming out, I’ve needed to reach more deeply into TW than I have before, and as I go, I learn just how much there is to learn.

It’s interesting that this is the sticking point. To me that was the simple part. I wrote this code because I wanted it myself on this project. I turned it into a plugin because:

  • I expect I would want it again on other projects
  • I thought others might possibly want to use it
  • it was a good way to learn more about Tiddlywiki

But I vacillated in writing the markup. I originally had three divs in a CSS grid. Something went wrong with that, and I temporarily switched to tables. Then I realized that there would occasionally be footers with multiple rows, and I kept the tables, even though I figured out what had been wrong with my first approach. (You know, in CSS “div” and “.div” mean very different things! D’oh!). But that vacillation made me think that a useful configuration possibility would be to allow the user to decide to override the footer markup. This was mostly a way to learn more about TW; I would love to get it into the plugin on my terms, but if I can’t, I’ve still learned a lot.

But I was stuck with the question that I’ve been asking in this thread; and I’m still mostly stuck, although I have three or four posts in this thread (including a recent one from you) to investigate. Perhaps a clean answer will eventually come through.

If that was what I was left with, I probably wouldn’t bother. The ViewTemplate is already its own tiddler. Anyone who had the TW skills to deal with the logic could simply override that tiddler in the first place. I’m not planning on offering additional views myself, only to offer that capability to others. I have what I need.

I haven’t looked at the implementation yet, but will soon. But after this long thread, I’m certainly coming to believe that this is not a solved problem.

Oh yes, if you look at the plugin, the HTML is simply structure and the CSS is used for all the design. I once considered myself quite good with CSS, but I haven’t kept up in the past decade. Still, those skills come back pretty easily.

Again, I have to thank you very much. This has all been very informative.

Ok, so that was random. I’m not quite sure what brought it to mind. But it was fun to look at.

Yeah, well now you’ve got me thinking, "How could I write a simpler Fibonnaci generator in wikitext. The only connection I can think of between TW and recursion is the potential error or recursive transclusion. Hmm…

Simulation of dynamic Array.

But I also have a couple of cognitive disorders going on, and everything is linked to everything. (And when I say everything, I mean everything there ever was, everything there is, and everything there ever will be. All intertwingled.)

Recursion in wikitext, no problem. Recursion that references the two previously generated values, that’s a challenge.

Recursion, fun. The rest of that problem: I had way more interesting, or more pressing, things to do.

That was a case of: this simple javascript that can be useful for a gazillion things, I much prefer put that javascript together, and then I can jump into those gazillion things right away. It was just about being able to quickly get to the fun-to-me stuff.

It’s not clear to me if it would make any difference to think of it as a single pair of values, equivalent to

const nFibs = (n, [a, b] = [0, 1], res = []) =>
  n < 1 
    ? res
    : nFibs (n - 1, [b, a + b], res .concat (a))

nFibs (10) => [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

Probably not, but I haven’t really thought the problem through yet, and it’s bedtime. But if you enjoy recursion and JS, you might like this:

And as I was in the process of making a snack I figured out exactly how to do the recursion thing with the two previously generated values without any javascript.

And now that I know how to do it, I’ve totally lost interest in actually doing it. The challenge isn’t there, so my interest is totally stifled.

That’s one of the effects of the cognitive disability: solve problems quickly, no ability to explain the solution, and lost interest when the solution is known. Everything is a shiny object, so many more interesting things to figure out.

Love recursion, loath javascript.

I will stare javascript in the eyeballs only if it solves more problems than it creates, and only if I can get it done and over with quickly.

But I do appreciate javascript for the good stuff people have done with it, and appreciate those who can stand working with it.

I use it mostly in an FP manner, and then its not bad at all.

Yeah, I wrote a popular FP library in JS to make it easier to do just that. So much JS you see in the wild is cringe-worthy.

I’d still love it if you’d be willing to share!

I wonder if I share this! :slight_smile:

To try and explain it, the effort required is way more than this kid can handle.

Quicker to just write the code, but then it is all work and zero fun.

Now to discuss just recursion in general (without getting into the Fibonacci Series, unless he really wants to…)

@EricShulman , if he’s up to chiming in, is a natural at explaining stuff eloquently and (my struggle) coherently as in not all over the map.

Just to see some simple recursion via macros, Eric’s A Simple Recursive TOC Macro is a beautiful showcase.

For general talk about recursion, the TiddlyWiki macro recursion I’ve done in BASIC Anywhere Machine is way too complicated a beast for casual consumption. (That recursion is for handling multi-tiddler inclusion of BASIC code, making sure to not duplicate any inclusions when many tiddlers in the inclusion tree are including the same tiddlers. The BASIC interpreter does not like duplicate code, so TiddlyWiki comes to the rescue.)

1 Like

I love recursion and its even more fun in Tiddlywiki because the inputs and conditions are the same thing, the “filters” and unless you “stuff up” filters outputs are finite so you do not need to concern yourself with the termination conditions such as WHILE and WEND loops.

A good solution using recursion, especially in tiddlywiki, once completed, looks deceptively simple, clean and short. And is of course very good, if not essential for iterating all elements of deep structure’s, eg a TableOfContents - just don’t swallow your tail :nerd_face:

1 Like

Ahh, Homoiconicity, that’s why I love recursion in LISP-like languages!

Nothing deceptive about it. If your data structure is recursive, a recursive technique will nearly always be more natural and more elegant. In these cases it’s iterative techniques that are deceptively complex!

I spend a lot of time on StackOverflow answering recursion questions.

1 Like

Ahh, the BASIC guy. I knew I’d seen your name. I keep looking at your code site, but never spend much time there at once. Easily distracted, you know. :wink:

I had my first sip of coffee, and thought: ok

The code below looks crappy. Better to click on the link and view in the Google Groups thread imported by TalkTiddlyWiki.

Yup, I am “that guy” …

I am a career OpenText Gupta Team Developer (aka Gupta SQLWindows) programmer. That’s been my bread and butter since 1995. That’s my favourite kind of programming language since 1993.

SQL programming is right up there.

For hobby programming, TiddlyWiki programming is the bomb.

My heart, though, belongs to BASIC.

Stupid and fun – I love it! Thanks for sharing.

I did line number basic back on the TRS-80, in maybe 1978 or 1979, Have barely touched it since, except for a few stints with VBA.

I’m more of an FP guy and love various LISPS. I admire Haskell, but mostly from afar. And my day job – while it touches C#, Python, Java, and occasional SQL – is mostly JavaScript, client and server side.

Well, my heart belongs to BASIC, but line numbers annoy the daylights out of me.

Totally off-topic, but my buddy’s creation, WasPentalive’s Trek, that’s my kind of BASIC programming.

In relation to the next/previous and tagging relationships raised in this thread;

I have opened a further discussion here Navigating complex tiddler relationships, a discussion for the enthusiast