In Arden, when you add one list to another, both the lists are flattened.
For example:
MyList1 := "cat", "dog", "hamster";
DeepList := MyList1, ("hyena", "elephant", "puma");
Now, DeepList
will not be a lists of lists as in:
("cat", "dog", "hamster"), ("hyena", "elephant", "puma") // 2 lists, 3 items each
But it will be flattened like so:
"cat", "dog", "hamster", "hyena", "elephant", "puma" // single list of 6 items
Is there a way to create a non-flattened list? It sometimes would be very useful to create such a list. I have searched the manuals and cannot find any way to do this. Searches online are fruitless--no one is putting up content about MLMs.
In plain vanilla "Arden Syntax for Medical Logic Systems" there is no way to do this. However, in Sunrise Acute Care's implementation, there are two ways to get a multi-level, non-flattened list in Arden.
The first way is by accessing a property of a list of objects. This non-flattened nature is due to the object-handling extensions added by Sunrise to normal Arden. First, create a list of objects that have a property set to a list.
Notes about
NEW AnimalObj WITH
: The extra comma is required to indicate that this is not the normal syntax of mapping parameters, where "cat" is the first property, "dog" is the second, and so on. Instead, we have to add the comma to force it to be a list of lists, removing ambiguity about how to interpret the list, indicating that the entire first value in parentheses is to be assigned to the first property. This incidentally demonstrates that lists do live in Arden as non-flattened during parsing & handling, which if you think about it is actually a required feature, because when calling MLMs it is perfectly legal to pass a list to the first parameter and a different list to the second. Any time you are trying to pass a single list as a parameter (so that the parser cannot deduce you intend the entire list as just one parameter), you must pay very close attention so that it is not interpreted incorrectly by the parser as a simple list of parameters--even with the extra parentheses around the parameters.Also note that in if you do a
BREAK;
and examine the value of the variableMultilevelList
, it will showcat, dog, hamster, hyena, elephant, puma
. This is highly misleading because it looks like a single list of 6 elements, but it is not, as we proved above withCOUNT
.The second way to get a non-flattened list in the SCM variant of Arden Syntax is to cheat and use direct Lisp code. We take advantage of the fact that parameters passed to an MLM are non-flattened. Create an MLM--I'll call mine
RETURN_ARGS
, and put this code in the denoted slots:This can then be used very simply from another MLM:
Close examination will prove that DeepList is exactly the same two-level list as produced with the object trick above.