Conditional sorting of columns in a matrix

I have a matrix with ten columns, and I want to rearrange these columns with three conditions.

  1. Column 1+2n and 2+2n (0<=n=<4) always remain together and in the same order (1+2n before 2+2n). Now we can say that we have five sets of columns, each having two columns.

  2. The 2+2n th columns should be sorted with respect to the first elements in them.

  3. In case first elements of any two 2+2n columns are same, they should be arranged with respect to the first elements of the corresponding 1+2n columns.

For example if the simplified matrix has only one row {1, 4, 7, 5, 8, 5, 0, 2, 3, 9}, it should be rearranged to {0, 2, 1, 4, 7, 5, 8, 5, 3, 9}.

Thanks for the help!

Solving generating conditional expression despite assumptions

Solve[(-f0 \[Pi]^2 wi^4 + \[Pi]^2 wi^4 z + f0^2 z \[Lambda]^2)/(    f0 wi Sqrt[((z^2 + (\[Pi]^2 wi^4 (f0 - z)^2)/(        f0^2 \[Lambda]^2)) \[Lambda]^2)/wi^2]) == 0 && z > 0 &&    wi > 0 && f0 > 0, z, Reals] 

This returns a conditional expression with the same assumptions that I have provided:

{{z -> ConditionalExpression[(     f0 \[Pi]^2 wi^4)/(\[Pi]^2 wi^4 + f0^2 \[Lambda]^2),      wi > 0 && f0 > 0]}} 

I know that I can simplify my conditional expression using some assumptions to get rid of this conditional expression wrapper, but this feels inelegant to me because it’s not seeing the assumptions that I gave it in Solve[].

How do I get Mathematica to recognize the assumptions I gave it in Solve[]?

Conditional widget for a listing archive page

I am building a listing website (using ListingPro theme)

Inside the Listing Archive page I added some advertising widgets and I need to add conditions to it so that different content is displayed according to the location.

For example, the user chooses location A, the widget displays ads for A. The user chooses location B, displays for B, and so on.

I tried using the Widget options plugin but I don’t know how to set the logic condition here: Widget options

Using the conditional tags from here:

This is the website I’m working on:

It has a search engine where you can choose a category and a location and then it shows a list of listings.

For example, if I search for the city of "Buenos Aires" it shows me the following link:

As you can see from the link Buenos Aires has the ID 1203. How could I set the logic condition inside the widget so that it shows according to the ID of the location you are looking for?

Any ideas? Thanks in advance!

Are conditional, sequential and looping instructions understood by an Unseen Servant?

In this question, the Unseen Servant was somehow compared to a computer, which got me thinking. As a programmer, I know that a computer, although mindless, is very good at fulfilling conditional (“if something is true then do this, else do that”), sequential (“do this then do that”) and looping (“do this while something is true”, and “do this for that amount of times”) tasks. Also, a computer is provided with a System Clock, and is therefore able to perform Waits. Therefore, this is a 7-in-1 question:

  1. Can an Unseen Servant fulfill conditional tasks? (ex : “pour wine into each empty glass” – in other words, if the glass if already filled, don’t pour wine in it, else do it)

  2. Can it fulfill sequential tasks? (ex: “pour wine into my glass, then bring it to me”)

  3. Can it fulfill looping tasks? (ex: “Pour wine into my glass every minute for 20 minutes”)

  4. If it can do all three separately, can it do them all together? (ex: “Every minute for 20 minutes, for each empty glass, if it’s empty, pour wine into it then bring it to their respective owner, else don’t touch it”)

  5. Can an Unseen Servant be fed a series of instructions via text (ex: “do what is written on this paper”) or speech (ex: “do what any of my Magic Mouths will tell you to do when one starts giving orders” – so if you have several Magic Mouths, the trigger of the second Magic Mouth’s speech might be something caused by one of the first Magic Mouth’s instructions to the Unseen Servant… which essentially results in something like a function call in programming)? For this to work, the Unseen Servant must either have sight+reading abilities, or hearing+language abilities. The spell specifies you give telepathic commands to the Servant, but does not say if textual/verbal commands from your own voice work as well. The closest thing is a comparison to a human servant, so it might or might not work out.

  6. Can an Unseen Servant wait for a given time interval before doing a task step ? (how it would work out : as it takes a turn (6 seconds) for an Unseen Servant to move 15 feet, it therefore takes it 1 second to move 2.5 feet, so if you tell an Unseen Servant to move in circles for 2.5X feet before doing a step, then you essentially delay the step by X seconds)

As soon as I can, I’ll put a big bounty on this question for the first person who puts a satisfying answer (either “yes” or “no”, as long as the explanation is very good and all 7 questions are answered) because it’s really important for me to get these answers.

Is there a way (and if so how) to add a conditional trait into PCGen?

Specifically what I am trying to do is add a racial trait to the Kitsune race that will replace two of the normal racial traits. I have successfully added a trait called "Naturally Skilled" into the program and it shows up/ works just fine however I need to cut out two of the other traits you would get naturally if you choose this trait.

Starting racial traits for a Kitsune: Agile, Change Shape, Kitsune Magic, Low-Light Vision

What it should look like if I choose Naturally Skilled is: Change Shape, Low-Light Vision, Naturally Skilled

So essentially I’m replacing both Agile and Kitsune Magic for Naturally Skilled. Is there a good way to code that in? I’ve been trying to find where in the code to put arguments like that but its like sifting through a barn full of hay for a hay colored needle.

Creating Conditional Fields in Elementor Custom Widget

How are conditional fields or field groups created in Elementor? I’ve not found anything in the documentation regarding conditional fields for widget development. A simple example of what I’d like to do is the following:

I have a dropdown:

    // Select Control     $  this->add_control(         'dropdown_Example',         [             'label' => __('Dropdown Example', 'vs'),             'type' => \Elementor\Controls_Manager::SELECT,             'options' => [                 'default' => __('Default', 'vs'),                 'yes' => __('Yes', 'vs'),                 'no' => __('No', 'vs'),             ],             'default' => 'default',         ]     ); 

If the answer in the dropdown is yes, then show text field 1:

    // Text 1     $  this->add_control(         'text1',         [             'label' => __('Text1', 'vs'),             'type' => Controls_Manager::TEXT,         ]     ); 

Else, show text field 2:

    // Text 2     $  this->add_control(         'text2',         [             'label' => __('Text2', 'vs'),             'type' => Controls_Manager::TEXT,         ]     ); 

Conditional formatting on data fetched from MYSQL

I’m not an expert in PHP and I’m trying to apply conditional formatting on data fetched from wpdb. To be fair, I’m trying to create shortcode for this. My motto is to fetch values for $ previous_marks & $ current_marks from the database and change the color of $ current_marks according to if, else condition. According to condition:

  • If $ current_marks > $ previous_marks, then value of $ current_marks should be displayed in green color along with pass.png image next to the value.
  • Else value of $ current_marks should be displayed in red color along with fail.png image next to the value.

I also need help in displaying images next to $ current_marks value & I have no code for it:

Here’s how my code looks like:

    add_shortcode( 'marks_col', function () {     $  subject = $  _GET['subject'];          global $  wpdb;     $  previous_marks = $  wpdb->get_results( "SELECT prev FROM grade WHERE sub='" .$  subject. "'");     $  current_marks = $  wpdb->get_results( "SELECT current FROM grade WHERE sub='" .$  subject. "'");     if ($  previous_marks < $  current_marks) {        echo "<p style="color:green">" .$  current_marks. "</p>"; ##display pass.png next to $  current_marks value     } else {        echo "<p style="color:red">" .$  current_marks. "</p>"; ##display fail.png next to $  current_marks value     }     } ); 

$ subject is fetched from the website’s URL: Currently, on using the shortcode [marks_col] on WP installation, it’s just printing ‘Array’ in red color & nothing else. Any help would be greatly appreciated.

Gravity Forms: How to add PHP function to confirmation conditional shortcode?

In Gravity Forms, I have a confirmation set up with various conditional shortcodes. Example:

[gravityforms action="conditional" merge_tag="{:3:value}" condition="contains" value="E"]*** GET A CATEGORY ***[/gravityforms] 

Additionally, I have a PHP function that gets all posts by category, and I would like to use this function inside the conditional shortcode. I’m not figuring out a way to do this, so any help would be appreciated.

My function: useful_tools_list(array( 'type' => 'documents', desc => 'true' ))

I also made it into a shortcode: [useful-tools type="documents" desc="true"]

I tried using <?php ?>, but I realized I can’t embed PHP into the editor. The conditional shortcode doesn’t support nesting other shortcodes inside of it, so that doesn’t work.

I’m wondering if there is a way to manipulate the GF conditional shortcode to allow nesting? Or another way of calling the function that I’m not aware of?