Accessing nested hashmap in freemarker - hash

I have the following structure where I need to access the list from the inner hashmap
Map(key, (Map (key, list ))
What is the easiest way to access the list in frermarker
Thanks in advance

Assuming the keys in the Map-s are Strings: foo[key1][key2][index]

Related

ADF passing more than one array paramater to LogicApps

I have an issue rearding the passing of more than one array parameter. I was able to do a "for each" cycle to execute my array parameter "SPPATH", but unfortunately I can pass only one, here is my code:
{"SPPATH":"#{item()}","SPFOLPATH":"#{pipeline().parameters.SPFOLPATH}","updsppath":"#{pipeline().parameters.updsppath}","Storageacct":"#{pipeline().parameters.Storageacct}","sapath":"#{pipeline().parameters.sapath}","saoppath":"#{pipeline().parameters.saoppath}"}
I want to pass "updsppath" also in the array because my output is on different locations, is it possible to do that, if so, how?
thanks in advance
I have reproduced the above and able to iterate multiple arrays inside ForEach.
For this the length of the all arrays should be same.
Use another array for indexes of these.
For Sample I have two array parameters like below.
I have created another array for index like below.
#range(0,length(pipeline().parameters.arr1))
Give this index_array to ForEach.
Create a res array variable in pipeline and inside ForEach, use append variable with the below dynamic content.
#json(concat('{"arr1":"',pipeline().parameters.arr1[item()],'","SPFOLPATH":"',pipeline().parameters.arr2[item()],'"}'))
After ForEach if you look at variable result (for showing here I have assigned to another variable), it will give you the desired JSON.
Result:
You can use this procedure to generate the desired array of objects and pass it to the logic apps as per your requirement.

How to sort an array filled with Timestamps?

I have a list where its elements are Timestamps in the form of
Timestamp(seconds=..., nanoseconds=...)
so I got
List myarr = [Timestamp(seconds=..., nanoseconds=...),Timestamp(seconds=..., nanoseconds=...),Timestamp(seconds=..., nanoseconds=...)]
How can I order this list? I have tried calling myarr.sort() but then I got the following error:
This expression has a type of 'void' so its value can't be used.
Try checking to see if you're using the correct API; there might be a function or call that returns void you didn't expect. Also check type parameters and variables which might also be void.
How can I sort the above mentioned array?
What is Timestamp? Is it perhaps firebase Timestamp?
Either way, it has to implement Comparable if it should be used without defining the sort method manually.
Otherwise you'll have to do myArr.sort((a,b) => "do your own sort")
For sort it in asc:
myarr.sort((a, b) => a.milliseconds - b.milliseconds);
For sort it desc
myarr.sort((a, b) => b.milliseconds - a.milliseconds);
Those are good answers, thank you. However, for me the following worked:
..sort()

Scala - finding a specific key in an array of tuples

So far I have an array of tuples that is filled with key,value pairs (keys are ints and values are strings).
val tuple_array = new Array[(K,V)](100)
I want to find a specific key in this array. So far I have tried:
tuple_array.find()
but this requires me to enter a key,value pair. (I think). I want to just search this array and see if the key exists at all and if it does either return 1 or true.(havent decided yet). I could just loop through the array but I was going for a faster runtime.
How would I go about searching for this?
find requires you to pass a predicate: function returning true if condition is fulfilled. You can use it e.g. like this:
tuple_array.find { tuple =>
tuple._1 == searched_key
}
It doesn't require you to pass a tuple.
Since this is an array, you have to go through a whole array at worse case (O(n)), there is no faster way (asymptotically) unless your array is sorted and allows usage of a binary-search (which isn't a part of the interface as you never knows if a random array is sorted). Whether you'll do this by iterating manually or through find (or collectFirst) doesn't affect the speed much.
but this requires me to enter a key,value pair. (I think).
No it doesn't, check the docs, you can just do:
tuple_array.find(_._1 == theKeyYouWant).map(_._2)
That returns an Option[V] with the value associated with the key if it was present. You then may just do an isDefined to return true if the key existed.
could just loop through the array but I was going for a faster runtime.
Well find just loops.
You may want to use a Map[K, V] instead of an Array[(K, V)] and just use contains
Also, as personal advice, it seems you are pretty new to the language; I would recommend you to pick a course or tutorial. Scala is way more than syntax.

How to compare with json object in Riot?

How to compare key value with object in riot?
am trying to compare key value with object in riot pleae suggest
First of all you should be more explicit in your question... What key and value do you want to compare with object? Why do you need riot to do that?
Anyway, you can use lodash API for comparing objects efficiently. If you really need riot you can use if conditional on the HTML element and use a function or inline comparison.
E.g.
<div if={ active: key === object }></div>
You should be more explicit if want appropriate answers

Get only the file names using listFiles in Scala

Is there an idiomatic Scala solution to obtain only the file names from File.listFiles?
Perhaps something like:
val names = new File(dir).listFiles.somemagicTrait(_getName)
and have names become a List[String]?
I know I can just loop and add them to a mutable list.
how about?
new File(dir).listFiles.map(_.getName).toList
I'm always wary of answering the wrong part of the question, but as Jean-Phillipe commented, you can get an array of the names from
new File(dir).list
and if you really need a list call toList on that.