As you see, the existent pairs are left as they are ([1,2] here), and each number is duplicated inside a list of two items: 0 becomes [0, 0], 2 becomes [2, 2] and so one.
To do it in Softanza, we will translate the logic above into near-natural language code, using the PerformW() function that executes a conditional action on each item of the list, and RepeatedInAPair() that turns a value into a pair of that value!
Here is the code, it's just self-explanatory:
o1 = new stzList([ 0, 2, 0, 3, [1,2] ])
o1.PerformW(
:do = '{ @item = Q(@item).RepeatInAPair() }',
:if = '{ Q(@item).IsANumber() }'
)
? @@S(o1.Content())
#--> [ [ 0, 0 ], [ 2, 2 ], [ 0, 0 ], [ 3, 3 ], [ 1, 2 ] ]
Thanks for sharing,
but the sample looks like a rare case (not common in practical)
You are doing a work of art, which is GREAT and I am looking for it to be in a usable state ASAP
Have a different look at the library and determine the important features and separate it from the rare features
It's better to provide the first release then get contributions from others
where you end up with a huge library that have many features and no one uses it except you
because of the huge learning curve
Instead of sending messages in the Group about the library
It's more important to improve the README.md file
And write the documentation along the development
Don't use simple examples that doesn't demonstrates the power of the library
No need to know PerformW() function, or @item and Q(@item) or :do or :if
This is not attractive (The library is too much better than this)
--
---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/a87c8d84-0738-4e18-adad-2a14710cda4fn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/354ba904-e9ee-47e8-94fc-21215aae8668n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/9191b887-5c2a-470d-9181-df68dd49ae53n%40googlegroups.com.