10

Below is a quick and unglamorous solution.

If you have a better one, please include it in your answer.

let tree_height = 15;
range i from -1 to tree_height * 2 step 2
| extend side_width = tree_height + 1 - i / 2
| extend side_space = strrep(" ", side_width)
| extend tree_part = case(i > 0, strcat("/", strrep("*", i), @"\"), " ^ ")
| project ta_da = strcat(side_space, tree_part, side_space)
                 ^                 
                /*\                
               /***\               
              /*****\              
             /*******\             
            /*********\            
           /***********\           
          /*************\          
         /***************\         
        /*****************\        
       /*******************\       
      /*********************\      
     /***********************\     
    /*************************\    
   /***************************\   
  /*****************************\  

If you need some inspiration: a Kusto Christmas tree

Yoni L.
  • 22,627
  • 2
  • 29
  • 48

3 Answers3

5

Here's my Khristmas tree:

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')

enter image description here

 

Michael Spector
  • 36,723
  • 6
  • 60
  • 88
5

Based on Yoni's answer - a similar implementation for Kusto Web Explorer (the web UI removes leading spaces from the result grid)

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

Result

enter image description here

0

Using scan operator:

let tree_height = 15;
let effective_height = tree_height+1;
range k from 0 to effective_height * 2 step 2
| extend spaces = strrep(" ", tree_height)
| extend parts  = strrep("*", tree_height*2)
| scan declare (k:long, w:long=0, side_space:string, tree_subpart:string, tree_part:string, christmas_tree:string) with 
(
    step s1: true =>    w               = effective_height - k / 2,
                        side_space      = substring(spaces, 0, s1.w),
                        tree_subpart    = substring(parts, 0, k),
                        tree_part       = strcat("/", s1.tree_subpart, @"\"),
                        christmas_tree  = strcat(s1.side_space, s1.tree_part, s1.side_space);
)
| where k > 3
| project christmas_tree

enter image description here

Aviv Yaniv
  • 6,188
  • 3
  • 7
  • 22