Is there an algorithm to switch from classical notation to concatenative stack-based notation?

Reading a bit about Joy, I was wondering if there wasn’t an algorithm to switch from classical notation and style to concatenative and stack-based style.

Of course, for simple mathematical expressions without variables, for example, you just have to convert the expression into the inverted Polish form:

f = 3 + 5 * (7 - 1) / 2  →  f = 3 5 7 1 - * 2 / + 

But what if our function has variables? It’s easy to find ourselves the expected result when the expression is simple, like here for example:

square(x) = x * x  →  square = dup * 

But for a more complex function, it becomes almost impossible to reason :

-- This is a Haskell code qsort [] = [] qsort (x:xs) = qsort ys ++ x : qsort zs     where         (ys, zs) = partition (< x) xs  →  qsort =     [small]     []     [uncons [>] split]     [enconcat]     binrec 

(According to Wikipedia, in the page linked above.)

So, is there any way to make a computer do this kind of conversion? (Also, should the order of the arguments in a function be reversed?)

I haven’t found any algorithm on the Internet that meets these expectations. It seems to me however to have searched well. I also imagine that a conversion like the quick sort function, as shown above, would probably be more complicated to generate, but I mean: the logic behind must be the same as a more simple expression.

My goal would simply be educational, I would be interested in seeing these conversions.

What happens when the UA Bait and Switch maneuver is used on a grappled ally when both the user and ally are still within the grappler’s range?

This question is based on this one: What happens when the UA Bait and Switch maneuver is used on a grappled ally when the maneuver-user is out of the grappling monster's reach?


The Unearthed Arcana Class Feature Variants includes the Bait and Switch fighter maneuver (page 5), which states:

When you’re within 5 feet of an ally on your turn, you can expend one superiority die and switch places with that ally, provided you spend at least 5 feet of movement. This movement doesn’t provoke opportunity attacks […]

What happens when the Bait and Switch maneuver is used on a grappled ally when both the maneuver-user and the ally are still within grapple range of the grappling creature?

I see two possible outcomes:

  1. The maneuver-user takes the ally’s place in being grappled, and can then attempt to break out of that grapple.

  2. The ally is still grappled, but has now been possibly moved to a more beneficial position.

I am not sure which of these would happen, as normally in a grapple the grappled creature cannot ever move. (And I might be confusing myself by trying to think of how this would even work IRL.)

With a USB Type-C port, can you switch DisplayPort or HDMI Alternate Mode back to USB after using an adapter? [on hold]

USB Type-C itself is just a connector, and it supports DisplayPort Alternate Mode, as well as HDMI Alternate Mode, depending on the manufacturer.

Does this at all mean that if you’re using a DisplayPort or HDMI adapter in your USB Type-C, e.g., on a MacBook Air, then the monitor’s side itself could switch back from the Alternate Mode of DisplayPort or HDMI back to the plain-old USB?

What happens when the new UA Bait and Switch Maneuver is used on a grappled ally?

The recent Unearthed Arcana Class Feature Variants includes the Bait and Switch Fighter Maneuver (page 5) which states:

When you’re within 5 feet of an ally on your turn, you can expend one superiority die and switch places with that ally, provided you spend at least 5 feet of movement. This movement doesn’t provoke opportunity attacks […]

The grappled condition states:

The condition also ends if an effect removes the grappled creature from the reach of the grappler or grappling effect, such as when a creature is hurled away by the thunderwave spell.

Assume a monster with a 5-foot reach is grappling an ally and the Fighter is adjacent to the ally 10-feet away. What happens if the Fighter tries to use Bait and Switch on the grappled ally?

For a picture format, F is the fighter, A the ally, and M the monster

FAM 

Command to switch to the last terminal tab

Is there a way to switch to the last terminal tab with some commands or bash script?

What I have got so far:

  • To switch to the next tab:

    xdotool key ctrl+Page_Down 
  • To get the number of terminal tabs:

    let terminal_counts=$  (ls /dev/pts/  | wc -l)-1 

Now I need to know how many times I need to execute xdotool key ctrl+Page_Down. How to know the current tab number?

How to represent a switch “tabbed” state in Material Design?

Trying to determine a way to represent a “tabbed” state on a switch that looks like this:

enter image description here

Under the hood, it is just a checkbox that the user can tab-over and press enter to check/uncheck the box.

What is a way that I can represent the active tabbed state on the switch specifically?

I have tried to add an outline/box-shadow, but I am using material design guidelines and don’t think this works with the clean-cut active states on text inputs etc.