This is a stripped-down version of a single section of Grok TiddlyWiki, optimized for fast loading and readability by search engines. Some features are missing.

For the full Grok TiddlyWiki experience, please visit the wiki version of this page.

Ex:MultiplyByTwoTwoWays

 28th September 2024 at 7:31pm

We saw two different ways to create a function that multiplies its input by two, depending on whether we wanted to take the multiplicand as an input tiddler or as a parameter:

\function multiply-by-two(number) [<number>multiply[2]]
\function multiply-input-by-two [multiply[2]]

<<multiply-by-two 4>>
{{{ [[4]function[multiply-input-by-two]] }}}

Create a multiply-anything-by-two function that works in either of these roles. That is:

\function multiply-anything-by-two(??) ??

* {{{ [[4]function[multiply-anything-by-two]] }}} should equal 8.
* {{{ [function[multiply-anything-by-two],[4]] }}} should equal 8.

  • ?? should equal 8.
  • ?? should equal 8.

Go to answer: Ex:MultiplyByTwoTwoWays/answer