Boolean functions

Today I realised that ‘and’ == ‘minimum’ and ‘or’ == ‘maximum’. Mind blown! :)

And here is some PHP code to go with my new found knowledge:

test( 0, 0 );
test( 0, 1 );
test( 1, 0 );
test( 1, 1 );

function test( $x, $y ) {

  if ( and_1( $x, $y ) !== and_2( $x, $y ) ) { echo "Error.\n"; }

  if (  or_1( $x, $y ) !==  or_2( $x, $y ) ) { echo "Error.\n"; }

}

function and_1( $x, $y ) {

  return (bool)min( $x, $y );

}

function and_2( $x, $y ) {

  return ! ( ! $x || ! $y );

}

function or_1( $x, $y ) {

  return (bool)max( $x, $y );

}

function or_2( $x, $y ) {

  return ! ( ! $x && ! $y );

}

New KDE Plasma widgets

So I upgraded my Ubuntu from 20.04 to 22.04. That mostly went without problem but there are still a few gremlins to iron out. One change was some of the desktop widgets I was using in the previous version seem to have been replaced. I found the replacements easily enough. I particularly like the new CPU activity widget, it’s a much more sensible way to visualise 24 CPU cores than the previous widget which just gave one reading instead of 24.