【问题标题】:How do I print a tree using the Kusto Query Language?如何使用 Kusto 查询语言打印树?
【发布时间】:2022-01-23 02:21:46
【问题描述】:

下面是一个快速而乏味的解决方案。

如果你有更好的,请在你的答案中包含它。

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)
                 ^                 
                /*\                
               /***\               
              /*****\              
             /*******\             
            /*********\            
           /***********\           
          /*************\          
         /***************\         
        /*****************\        
       /*******************\       
      /*********************\      
     /***********************\     
    /*************************\    
   /***************************\   
  /*****************************\  

如果您需要一些灵感:

【问题讨论】:

    标签: azure-data-explorer kql azure-sentinel kusto-explorer azure-monitor


    【解决方案1】:

    这是我的圣诞树:

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

     

    【讨论】:

      【解决方案2】:

      基于 Yoni 的回答 - Kusto Web Explorer 的类似实现(Web UI 从结果网格中删除前导空格)

       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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-11
        • 1970-01-01
        • 2023-01-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多