Remove empty terms from array, sort alphabetically, update back to repeating field

I have a repeating field that stores text terms in an array, like this:

[0] =>  [1] => NUC Lights [2] => Smoke Alarm [3] => Binoculars 

You’ll note key A has no value, and they’re not ordered alphabetically. What I want to do is to take the array above, remove empty values, sort it, and resave it like below:

[0] => Binoculars [1] => NUC Lights [2] => Smoke Alarm 

Here’s my current code:

// Post Types to include $  post_args = array(     'posts_per_page' => -1,     'post_type' => array(         'boat'     ), );  // The Query $  post_query = new WP_Query( $  post_args ); $  posts = $  post_query->posts;  foreach($  posts as $  post) {      $  boat_safety_terms = get_post_meta( $  post->ID, 'wpcf-all-safety-terms', false );     $  boat_safety_terms_cleaned = array_filter( $  boat_safety_terms );     $  boat_safety_terms_cleaned_sorted = sort( $  boat_safety_terms_cleaned );      error_log( print_r( $  boat_safety_terms_cleaned_sorted, TRUE ) );  } 

But my log only shows 1 for each boat for some reason. Any idea what might be going wrong with it?

Also, I’m assuming I’ll want to use update_post_meta to save the array back to the field?

Are the definitions of constructs in terms of lambda terms issues in implementation/design or uses of functional languages?

In Lambda Calculus, natural numbers, boolean values, list processing functions, recursion, if function are defined in terms of lambda terms. For example, natural numbers are defined as Church numerals, and recursion is defined in terms of a fixed point of a function.

Functional languages are said to be based on Lambda Calculus.

Who shall be concerned about the above concepts in terms of lambda terms: the implementer/designer of the languages, and/or programmers in the languages?

  • Do functional programming languages define/implement the above concepts in terms of lambda terms?

  • As programmers in regular functional programming languages (such as Haskell, Lisp, ML), is it correct that the above concepts are always given in the same way as in imperative languages, and we never have to understand or deal with their definitions in terms of lambda terms?


Search Results web part populating without any search terms being entered into Search Box web part

I am having the same issue as the user in this link: Search results webpart displaying items without search box query

I have a Search Box web part + Search Results web part (and my result source is a wiki enterprise page). Before any terms are entered in Search Box, all possible results are displaying in the Search Results. Again, this is before any search is actually performed. All answers in linked article have been attempted, and all have failed.

Is there a way to have Search Result web part not display any results until a search has actually been performed by the user?

Thanks so much!

Is there a unit of measurement that can express code execution speed in absolute terms?

I’ve always seen code execution speed measured either in units of time (e.g. t milliseconds), or using asymptotic analysis (e.g. O(n log n)). These methods are relative to hardware performance though, they’re not absolute terms.

For space performance, we have the same asymptotic analysis, but we can also measure that performance in bytes, which allows us to express (and predict) space performance in both relative and absolute terms. e.g. algorithm X’s space complexity is O(n) or n * 32 bytes of memory for implementation Y in language Z.

For example we can look at this code:

for i in n:     pass 

And if we know this will be executed using a 64-bit build of CPython, we can say this for loop will take up 72 + n * 8 bytes for the integer array and 8 bytes for each reference (independent of context/overhead).

My question is: Is there a unit of measurement we can use to express a piece of code’s execution speed (or CPU usage) in absolute terms, similar to bytes for memory?

Where can I download a dictionary of computer technology terms for natural language processing? [on hold]

I am doing some natural language processing in R of a moderately sized corpus. I am cleaning up the corpus to remove nonsensical terms (e.g. escape/typesetting characters, URLs, HTML code). Part of the process involves filtering words found in a standard dictionary. My dictionary needs to be augmented to include computer technology terms e.g. “iot”, “app”, “drm”, “hdd”, “ssd”, “ram”, and so forth.

Can anyone point me to an up-to-date downloadable resource?

Many thanks.

Build Isotope filter groups with category terms

Sorry for the large question. I’m a bit lost and I want to provide all data possible for problem understanding. There are two options for achieve the goal. First, build the markup with a walker, second, build the markup iterating an array. The main question is how to build it with a walker. Althought I provide my attempt to build it with an array in order to ask weather it is a good practice.

I have this category terms structure:

term-1-level-1     term-2-level-2     term-3-level-2     term-3-level-2     term-4-level-2 term-5-level-1     term-6-level-2     term-7-level-2     term-8-level-2 

Trying to build this markup from category terms:

<div class="button-group filter-button-group">   <button data-filter=".term-1-level-1">     term-1-level-1</button>   <button data-filter=".term-2-level-2">     term-2-level-2</button>   <button data-filter=".term-3-level-2">     term-3-level-2   </button>   <button data-filter=".term-4-level-2">     term-4-level-2   </button> </div>   <div class="button-group filter-button-group">   <button data-filter=".term-5-level-1">     term-5-level-1</button>   <button data-filter=".term-6-level-2">     term-6-level-2</button>   <button data-filter=".term-7-level-2">     term-7-level-2   </button>   <button data-filter=".term-8-level-2">     term-8-level-2   </button> </div> 

The question is: Is it possible to build it with the walker class? I tried extending Walker and Walker_Category, unsuccesfully, this way:

class Isotope_Walker extends \Walker {      public $  tree_type = 'category';      public $  db_fields = array ('parent' => 'parent', 'id' => 'term_id');      function start_lvl(&$  output, $  depth=0, $  args=[]) {         $  output .= "\n<div class=\"button-group filter-button-group\">\n";     }      function end_lvl(&$  output, $  depth=0, $  args=[]) {         $  output .= "</div>\n";     }      function start_el(&$  output, $  category, $  depth = 0, $  args = [], $  id = 0) {         $  output .= '<button>' . $  category->name;     }      function end_el( &$  output, $  page, $  depth = 0, $  args = []) {         $  output .= '</button>';     }  } 

In other hand I know that I can build an array with terms for iterate the array, this way:

public function filters()     {         $  terms = get_terms( array(             'taxonomy' => 'category',             'hide_empty' => false,         ) );          foreach ($  terms as $  term) {             if ($  term->parent === 0 && $  term->slug != 'no-category') {                 $  parents[] = [                     'id' => $  term->term_id,                     'name' => $  term->name,                     'slug' => $  term->slug,                 ];             }         }          foreach ($  parents as $  parent) {             $  parent_id = $  parent['id'];             $  {'parent_childs_' . $  parent_id}['parent_' . $  parent_id] = $  parent;             foreach ($  terms as $  term) {                 if ($  term->parent === $  parent_id ) {                     $  {'childs_of_' . $  parent_id}[] = [                         'id' => $  term->term_id,                         'name' => $  term->name,                         'slug' => $  term->slug,                     ];                 }                  if (isset($  {'childs_of_' . $  parent_id})) {                     $  {'parent_childs_' . $  parent_id}['childs_' . $  parent_id] = $  {'childs_of_' . $  parent_id};                 }             }              $  output['parent_childs_' . $  parent_id] = $  {'parent_childs_' . $  parent_id};          }          return $  output; } 

This returns:

array (size=3)   'parent_childs_3' =>      array (size=2)       'padre_3' =>          array (size=3)           'id' => int 3           'nombre' => string 'Artes visuales' (length=14)           'slug' => string 'artes-visuales' (length=14)       'childs_3' =>          array (size=6)           0 =>              array (size=3)               'id' => int 4               'name' => string 'Escultura' (length=9)               'slug' => string 'escultura' (length=9)           1 =>              array (size=3)               'id' => int 4               'name' => string 'Escultura' (length=9)               'slug' => string 'escultura' (length=9)           2 =>              array (size=3)               'id' => int 4               'name' => string 'Escultura' (length=9)               'slug' => string 'escultura' (length=9) 

So, I can iterate it and build the markup without walker. Regarding this method, I would like to ask if it is a good practice or is better the walker way.

Thank you!