How to continue a list item after a sublist - nested-lists

I would like to have some descriptive text in a list item after a sublist.
How to achieve that in Asciidoc?
Here is the structure I would like to have:
A list item of the main list
Then a sublist with some list item
Just another sublist item to give the sublist sense
And after the sublist some more descriptive text.
A subsequent item of the main list.
What I have tried:
Starting point:
* A list item of the main list
** Then a sublist with some list item
** Just another sublist item to give the sublist more sense
*And after the sublist some more descriptive text.*
* A subsequent item of the main list.
The comment //-- ends the main list. So it is not helpful at this point.
Stuff like multiple newlines does not help to end a sublist.
In Orgmode the following code gives the desired layout:
- A list item of the main list
- Then a sublist with some list item
- Just another sublist item to give the sublist more sense
*And after the sublist some more descriptive text.*
- A subsequent item of the main list.

See attaching blocks to an ancestor list.
For example:
* A list item of the main list
+
--
** Then a sublist with some list item
** Just another sublist item to give the sublist more sense
--
+
*And after the sublist some more descriptive text.*
* A subsequent item of the main list.

Related

Count total rows excluding children rows

I have a requirement for display only row count of parent rows in tree data mode. I am using getDisplayedRowCount api it gives me all the row count i.e parent + child (if expanded). Is there any way to do it?
For example
If we have rows like below where 2 row has child and 1 row has no child then just count as 3 . dont count children. Just count parent row and row without children
Result count : 3 of 3
Parent row 1
--- Child row
Parent row 2
--- child row
Row without child
For example, if we have tree structure like in the example . How to only count A, C and E? and show count as 3 on top of grid
https://www.ag-grid.com/example-runner/grid-react.php?section=javascript-grid-tree-data&example=filler-nodes&generated=1&clientside=1&rowgrouping=1&enterprise=1&grid=%7B%22noStyle%22%3A0%2C%22height%22%3A%22100%25%22%2C%22width%22%3A%22100%25%22%2C%22enterprise%22%3Atrue%7D
https://www.ag-grid.com/javascript-grid-tree-data/
One possible solution would be to rely on the fact that the parent node of the nodes A, C & E (in your given example) is the root node - note that this is not documented in the official documentation, however it is the simplest solution I can think of.
If a node has the root node as the parent, then we can call it a parent node.
You can verify this by adding this code and look at the nodes which are printed:
gridOptions.api.forEachNode((node) => {
if (node.parent.id == 'ROOT_NODE_ID') {
console.log(node.key);
}
});
I've put together an example showing this at the click of a button

How to use add elements to a matrix?

I want to add multiple items from one list to another list, that is organized in one big list, like a matrix.
let targetlists (list firstlist seccondlist thirdlist)
So in my double while loop, I added this code;
set (item x targetlists) lput (item y sourcelist) (item x targetlists)
Sadly it gives me the following error:
This isn't something you can use "set" on.
I found out that it has to do with how I select the target list, as the following code does work, but doesn't do what I want:
set firstlist lput (item y sourcelist) firstlist
JenB is right that, in general, you use replace-item. However, replacing your while loops with map will be much more effective.
I'm not entirely sure what you're trying to do, but it looks like you're trying to put the elements of sourcelist onto the end of the lists in targetlists. Even if that's not what you're doing, this should point you in the right direction:
set targetlists (map [ [ source-item target-row ] ->
lput source-item target-row
] sourcelist targetlists)
This will iterate through the items of sourcelist and targetlists together, calling lput on the pairs.
Also, there's a handy shortcut where, if a reporter already does what you want, you can pass it directly to map. So you can condense this to:
set targetlists (map lput sourcelist targetlists)
Now, given that you mentioned nested whiles and you're indexing into the two lists with two different indices, you might be trying to put the entire contents of sourcelist onto the ends of each of the targetlists. If that's the case, you can just do
set targetlists map [ l -> (sentence l sourcelist) ] targetlists
If I'm totally off, and you're trying to do something completely different, just let me know in the comments and I'll update my answer.

How to compare two lists in Netlogo?

I have two breeds, buyers and suppliers, and buyers are building a list (sup_list) of suppliers that have attributes stored in list 'att' that are greater than a list of criteria stored in list 'b'. The following line does this for the first criteria - is there an easy way to add in all the others?
ask buyers [set sup_list suppliers with [item 0 att > [item 0 b] of myself]]
So in English the criteria would be: item 0 > item 0 AND item 1 > item 1 AND item 2 > item 3 etc.
Thank you.
The expression you want is:
suppliers with [ reduce and (map > att [ b ] of myself) ]
This is a tricky bit of functional programming. Let's see how it works.
Our first goal is to take the two lists of numbers and turn it into a single list of boolean values, where each item will be true if the item at the same location in the buyer's list is greater than the item at the same location in the supplier's list. For example, if we have:
Buyer's list: [1 1 1 1]
Supplier's list: [2 1 1 1]
...only the first item in the supplier's list fits our criteria, so we want our resulting list to be:
[true false false false]
Whenever we want to turn one or more lists of things into a single list of things, the NetLogo primitive to use is map. The map primitive takes a reporter and one or more lists. It applies the reporter to item(s) taken from the list(s) and builds a new list out of that. This is exactly what we need. Try this in the NetLogo command center:
observer> show (map > [2 1 1 1] [1 1 1 1])
observer: [true false false false]
A couple of things to note:
Since we are passing more than one list to map, we need to put the whole expression inside parentheses.
We are using concise syntax for passing > as a reporter. This could also have been written [ [a b] -> a > b ].
Now that we have our list of boolean values, we want to check if all these values are true, i.e., if all supplier items fit the buyer's criteria. NetLogo has an all? primitive that does something like that for agentsets, but we cannot use it here since we are dealing with a list. We will have to use reduce instead.
The reduce primitive is the one to use whenever we want to turn a list into a single value. Here, we want to turn a list of booleans into a single boolean value, that will be true if all the values in the list are true and will be false otherwise.
As the NetLogo documentation says, "it can be difficult to develop an intuition about what reduce does". (I strongly urge you to read the documentation and try experimenting with the primitive.) In a nutshell, it traverses a list and applies a reporter to each item and an "accumulator" value, storing the result of that operation in the accumulator. The first item of the list is used to initialize the accumulator.
In our case, the reporter used with reduce will be and, since we want to check that the first item is true, and that the second item is true, and that the third item is true, etc.
Let's try to reduce our previously obtained list of booleans:
observer> show reduce and [true false false false]
observer: false
(Not that we're, again, using the concise syntax to pass and as a reporter. This could have been written [ [p q] -> p and q ].)
The end result is false, because not all values are true. Let's see how this works, step by step:
it stores the first item from the list in the accumulator, so the accumulator now holds the value true.
it passes the value of the accumulator and the value of the second item to the and reporter. The accumulator is true but the second item is false. The result of true and false is false, so it stores false in the accumulator.
it passes the value of the accumulator and the value of the third item to the and reporter. The accumulator is now false and the second item is also false. The result of false and false is false, so again, it stores false in the accumulator.
the fourth step is just like the third: the accumulator holds false and the fourth item is also false. The result of false and false is false, so again, it stores false in the accumulator.
Once we run out of list items, reduce reports the value of the accumulator, in this case false. The only case where it would report true is if all values in the list are true, leading to a sequence of true and true comparisons that all result in storing true in the accumulator. That's exactly what we want:
observer> show reduce and [true true true true]
observer: true
If you put all of this together, you should be able to see how:
suppliers with [ reduce and (map > att [ b ] of myself) ]
...gives you the agentset of suppliers that fit all criteria of the buyer!
(Note that with returns an agentset, not a list, so you should probably rename your sup_list variable...)

Continuing the list with checkboxes

Suppose that the cursor is currently after the word "bread" at the end of this piece:
* TODO Week1 [/]
SCHEDULED: <2015-08-09 Sun>
- [ ] Buy bread
When I press Alt-Enter, it adds a list item, but not a checkbox. Can I modify this behavior, so that a list that starts with a checkbox would continue with checkboxes as well?

jquery selector - how to sort the iterated objects

Let say there are 3 divs Div1, Div2, Div3 and all have the class "ui-selected"
To iterate the div selection you can use something like below
$(".ui-selected").each(...)
The above iteration, references each div in the same sequence as they are added to the Document.
How do we sort the selection.
For e.g if Div1 represents a value of 30, Div2 represents value of 10 and Div3 a value of 40
the iteration when sorted should be as
Div2 , Div1 and Div3.
Right now the list iterates in the order of how they belong in the Doc model.
Is there a way to sort the jquery selection?
Assuming you have a way to know the "value" of each div, you can use the sort method.
$(".ui-selected").sort(function(a,b){
//sorting logic here
}).each(...);