Tuesday, December 21, 2021

Happy Holidays! Draw a tree with KQL

KQL isn't just super-powerful, it's also fun!
See how you can draw a tree using KQL and learn some of the functions and operators available.
Inspired by https://lnkd.in/eCgFzBTw. Feel free to design your own trees!

 

let tree_height = 10;
range i from 0 to tree_height * 2  step 2   
| extend side_width = tree_height + 1 - i / 2
| extend side_space = strcat_array(repeat(" ", side_width), " ")
| project Happy_Holidays = case(i != 0, strcat(side_space, "O", strcat_array(repeat("V", i - 1), ""), @"O", side_space), 
strcat(side_space, " O", side_space))


Holidays.png

 

let L=10;
range x from 1 to L step 1
| project t=strcat(strrep(' ', L-x), strrep('.', x), strrep('*', x-1))
| summarize Tree=make_list(t)
| project Tree=array_concat(pack_array(strcat(strrep(' ', L-3), make_string(127775))), Tree)
| project HappyXmas=strcat_array(Tree, '\n')


Holidays2.png
 

 

Posted at https://sl.advdat.com/3sqS3sK