google sheets – IF function that leaves the last number calculated if statement is true/false

I am trying to write a formula that updates a number in the cell if another cell is empty, and leaves the last number calculated if the other cell is not empty. I am calculating my profit, which changes until I actually collect it. So far I have this:
=IF(ISBLANK(K2),C2-H2,())
Obviously it is not possible to do this. Prove me wrong

beginner – GetNeighborhood function for 3D cells structure in MATLAB

I am attempting to implement a GetNeighborhood function in order to get a specific region from inputCells by sizeInput and centralLocation parameters in 3D cells structure.

The experimental implementation

The experimental implementation of GetNeighborhood function is as below.

function (output) = GetNeighborhood(inputCells, sizeInput, centralLocation)
    %   Get neighborhood of fixed size and centered at centralLocation
    output = cell( sizeInput ,sizeInput ,sizeInput );
    X = centralLocation(1);
    Y = centralLocation(2);
    Z = centralLocation(3);
    for x = -sizeInput:sizeInput
        for y = -sizeInput:sizeInput
            for z = -sizeInput:sizeInput
                if X + x < 1
                    xLocation = 1;
                elseif X + x > size(inputCells, 1)
                    xLocation = size(inputCells, 1);
                else
                    xLocation = X + x;
                end
                
                if Y + y < 1
                    yLocation = 1;
                elseif Y + y > size(inputCells, 2)
                    yLocation = size(inputCells, 2);
                else
                    yLocation = Y + y;
                end
                
                if Z + z < 1
                    zLocation = 1;
                elseif Z + z > size(inputCells, 3)
                    zLocation = size(inputCells, 3);
                else
                    zLocation = Z + z;
                end
                
                output{sizeInput + x + 1, sizeInput + y + 1, sizeInput + z + 1} = ...
                    inputCells{xLocation, yLocation, zLocation};
            end
        end
    end
end

Test cases

For testing purpose, a simple test script is created as below.

clear all;
clc;
close all;
set(groot,'defaultFigureVisible','on');

%% Create test cells

testCellsSize = 10;

test = cell(testCellsSize, testCellsSize, testCellsSize);
for x = 1:size(test, 1)
    for y = 1:size(test, 2)
        for z = 1:size(test, 3)
            test{x, y, z} = (x * 100 + y * 10 + z);
        end
    end
end

%% Specify test parameters

NeighborhoodDist = 1;
centralLocation = (5 2 2);

%% Perform test

result = GetNeighborhood(test, NeighborhoodDist, centralLocation);
result

If there is any possible improvement about potential drawback or unnecessary overhead, please let me know.

SQL function on a javascript variable

I have a javascript file that receives a number like “1345”, and in order to insert it into a table, I need to find a way to apply an specifiq SQL command on it.

This is the code that I have:

var stime = traffic.startTime;
var dateNow = new Date().toLocaleString('pt-BR', {
            timeZone: "America/Sao_Paulo"
        });

conn.executeUpdate(
            'INSERT INTO "SCHEMA"."TABLE" VALUES (?,?,?,?,?,?,?,?,?)',
            val1, val2, val3, val4, stime, val6, val7, new Date(dateNow), null);

what I need is to apply the SQL function to_time to the variable stime and then, run the insert. so to_time(stime, HHMI).

How can I do that?

Obs: I don’t wanna manipulate the number in js, it’s gotta be in SQL.

php – WordPress schedule event function not running

I am totally new with the schedule event from WordPress.
For my theme I created a function that must run every minute.
To test my scheduler I created a test function that send me an email.
But I do not receive an email and I think my scheduler is not working.
Please who can help me a bit?
Below my code so far

add_action( 'my_test', 'test_scheduler');
add_filter( 'cron_schedules', function ( $schedules ) {
   $schedules('per_minute') = array(
       'interval' => 60,
       'display' => __( 'One Minute' )
   );
   return $schedules;
} );

//create event after theme setup
add_action("after_setup_theme", function(){
    if (! wp_next_scheduled ( 'my_test' )) {
        wp_schedule_event( time(), 'per_minute', 'my_test' );
    }
});

//delete event if theme is deactivated
add_action('switch_theme', function(){
    wp_clear_scheduled_hook( 'my_test' );
});

The code above is in the functions.php file.

node.js – How to use Function in discordbot using client.commands.get(“servertest”).run(client, message)

i want that it start my function,
So what happens now it executes the function but it spams the execution unlimited times…
The data from data.ref is a number and when it matches the number it executes the function, but its only now and then..

what can i do to prevent this? a timeout function doesnt work.. it still keeps spamming

for (var i in config.Extra) {
        if (myData.ref == config.Extra(i).ref) {
        
            var Alert1Type = config.Extra(i).Alert1; // type of the device show
            var Alert1Name = config.Extra(i).name; // Custom name show
            
        

        
            console.log('test');
            test() //starts the function
         
            
        }
}

function test(){

    client.on('message', message => {
    client.commands.get('servertest').run(client, message); 
    return 
})

}

How can I implement a function that is a homomorphism?

I want to do the follow: Write a function $f$ such that if I evaluate $f(ax+by)$, it returns $f(a)f(x)+f(b)f(y)$. How can I do that? I tried to look in the help for "homomorphism" but didn’t find anything. I suspect there might be another name for this kind of functions in Mathematica.

Dataset: selectively map a function onto the nth column

I have this data, which I used the following to Import.

c=Import("data1.csv", "Dataset", HeaderLines -> 1);
d=c(All, {1 -> ToExpression});

enter image description here

I want to convert the 1st col to Minute and want to use the dataset(All,{n->f}) mentioned in MMA’s Dataset document. My idea to operate a function on the 1st col and return a two-col dataset. I tried the following. Some worked, while some did not. Could you please have a check and comment on why some methods did not return what I want. Thanks.

Those worked.

f = UnitConvert(#, "Minutes") &;
d(All, {1 -> f})
d(All, {"t" -> f})

d(All, {"t" -> Function({x}, UnitConvert(x, "Minutes"))})

Those did not.

d(All, {1 -> UnitConvert(#, "Minutes") &}) (*I understand why this one did not work.*)
d(All, {1 -> UnitConvert(#((1)), "Minutes") &})
d(All, {"t" -> UnitConvert(#((1)), "Minutes") &})

This simply blowed my mind. I wanted to return the 1st col itself. However, 1 seems to work as #((1)) and 2 as #((2)). It seems to me anything appears on the right hand left is treated as a Function (Here, as Part)?

d(All, {"t" -> 1})
d(All, {"t" -> 2})

replacement – Apply a function to all coefficients of a polynomial

Here’s one way:

rules = CoefficientRules(P, {x, y})
newrules = MapAt(f, #, 2) & /@ rules
FromCoefficientRules(newrules, {x, y})

Or, in general,

CoefficientMap(f_, P_) := FromCoefficientRules(
   MapAt(f, #, 2) & /@ CoefficientRules(P, Variables(P)), Variables(P))

CoefficientMap(f_, P_, vars_) := FromCoefficientRules(
   MapAt(f, #, 2) & /@ CoefficientRules(P, vars), vars)

In general, if you replace MapAt(f, #, 2) & with a function which takes Rule(powerlist, coeff) to Rule(newpowerlist, newcoeff), you could build more general maps on polynomials! (Currently, MapAt(f, #, 2) &(Rule(p, c)) yields Rule(p, f(c)).)

For the application you mention later on, though, where you change Sin(2 x) to Sin(4 x) it sounds like you might want to build your own version of Variables or CoefficientRules for that situation which would extract and encode Fourier coefficients of finite Fourier series (or something like that)—possibly by converting them into polynomial variables in their own right.

google sheets – How to add arrayformula function to this formula with IF function?

I made a table that has two columns (namd & State). The 4th column(check) makes conditional formatting possible for any of these combinations: (if name is either “Ali” or “John”, AND state is “FL”), a conditional formatting rule is applied only if the cell value of E2 is “NO”.

I had to repeat this formula for all rows and I failed to wrap it in an arrayformula function.

I tried this but failed:
=if(OR(AND(C2="John",D2="FL",$E$1="No"),AND(C2="Ali",D2="FL",$E$1="No")),1,0)

adding arrayformula:
=ArrayFormula(if(OR(AND(C2:C="John",C2:D="FL",$E$1="No"),AND(C2:C="Ali",D2:D="FL",$E$1="No")),1,0))

https://docs.google.com/spreadsheets/d/17mmduo0em4PK0FDPxIRTX36CqhW6woI4jdyPSJaiGAM/edit#gid=1414263054

fa.functional analysis – Is the graph of a Sobolev function path connected?

Let $Omega$ be a bounded, open, simply connected subset of $mathbb R^n$ with Lipschitz boundary.

Question: Does every function in the Sobolev space $W^{1,1} (Omega)$
admit a representative whose graph in $Omega times mathbb R$ is
path connected?