construction of the function – Obtaining a non-zero output of all parts of a compound expression

I decided to post this question and this personal answer as this could be helpful to other people wishing to do the same thing.

I was wondering how to get a non-zero output of all parts of a compound expression. By default, only the result of the last part of a compound expression is generated, for example:

fun1[expr_] : = (expr + x; expr + y; expr + z)
fun1[a]

a + z

fun1p: = (# + x; # + y; # + z) &
fun1p[a]

a + z

We could use Print (or Echo) …

fun2[expr_] : = (Print[expr + x]; Impression[expr + y]; Impression[expr + z])
out2 = fun2[a]

a + x

a + y

a + z

… but the output has Null content:

out2

(no output)

The same result is obtained using Print with a pure function.

There are workarounds, but sometimes I find it very convenient to get the outputs directly.

NOTE: There is no duplication of compound statements and previous results returned in parentheses () because the PO was trying to print the results (which displays the results, but the content is Null), whereas I (as explained above) want to: actually get the results (such as I can assign them to variables).

output format – Combination of pure functions containing compound expressions

For display, I sometimes find it desirable to undo the canonical order of the Mathematica variables and to make it display the terms in the order in which I type them. For example, instead of this:

b-a
v = v0 + t
a8 + a9 + a10

-A + b

a t + v0

a10 + a8 + a9

… I would prefer this:

b – a

v0 + t

a8 + a9 + a10

This can be easily accomplished by removing the Orderless attributes from Plus and Times, entering the expression, and immediately restoring these attributes (it is important to do so because their absence alters the basic functionality; for example, without Orderless, Plus does not work, recognize that a + b is mathematically identical to b + a).

ClearAttributes[Plus, Orderless]
ClearAttributes[Times, Orderless]
c (b-a)
SetAttributes[Plus, Orderless]
SetAttributes[Times, Orderless]

c (b – a)

How can I implement the above as a function? That is, I would like to define a function such as:

func[c (b-a)]
c (b-a) (* confirms that Orderless is restored on both Plus and Times *)

c (b – a)

(-A + b) c

Up to now, I have managed only the following, which allows to obtain the desired result, but requires that I enter a function, then the expression, then another function:

func1: = (ClearAttributes[Plus, Orderless]; ClearAttributes[Times, Orderless]) &;
func2: = (SetAttributes[Plus, Orderless]; SetAttributes[Times, Orderless]) &;
func1[_]; c (b-a)
func2[_]
c (b-a)

c (b – a)

(-A + b) c

How do I combine them into one function that takes expression as an argument?

EDIT: Note that I only want to change the display format, not any other feature. For example, the MMA should always recognize that e1 and e2 are mathematically equivalent:

func1[_]
e1 = c (b - a)
e2 = (-a + b) c
func2[_]
e1 == e2

c (b – a)

(-a + b) c

True

[get] compound | Black Hat Forum on SEO and Affiliate Marketing

The hidden 3-digit method by DayOnline PROVEN PROFIT

Do not take our word for it

This is what real people

Are about Compoundly:

Rash Wine

Wow! Honestly, I can not believe that these guys are releasing this system at the price that they are. I saw Paul and Anthony quietly crush him with this method for a while. I was not sure if they were going to publish it or not. Well done guys, this will help a lot of people and create success stories for sure.

Andrew Speers

Hello is Andy Speers from Bangkok, AKA Bangkok-Blacksmith. Long-time friend and promoter of Anthony Mancuso's award-winning products. Do not forget the EZ Passive pay days, full of training. On the verge of launching another mortgage repayment program for Christmas.

About 10 packaged information videos. Get early for the sale of dimes a blue print that earns between $ 5 and $ 10,000 a month. Dive deeper into OTO 1 and get ready for funnels. It does not end there. I recommend Anthony, he is a winner.

Steven Banks

What an incredible training guys. This is precisely what the industry needs now: a surefire way to make money online, with which even the little guy can succeed. Good game!

Warning Price increases in:

Forget the competition, the experience or the payment of announcements – This UNTAPPED system works for everyone.

[proof inside]

  • Untapped and proven method for fast and consistent cash balances in ANY time slot
  • Suitable for beginners at 100% – no technical or technical experience required
  • Be active, on the go and make money in 24 hours or less
  • Totally free traffic – never pay for ads again!
  • BUILT-IN Scale – Stay Seated and Watch Your Profits Rise to Achieve Critical Income
  • Do more for less – free traffic and 30 minutes a day, that's all it takes to accumulate money
  • BATTERY PROOF – results for over 3 years and complete beginners crushing with this method

link to the sales page

ACCESS

member space link

ACCESS

link to the bonus page

ACCESS

java – Is a setter with a compound object as a parameter a better parameter or separate parameters for each parameter of the compound object?

I have two ideas on how to proceed with an availability class, but I'm not sure which one is the best.

Public class TimeRange {
private time stamp startTime;
private endTime timestamp;

public TimeRange () {
// set default values
}
// appropriate getters
// setters
public void setStartTime (Timestamp startTime) {
this.startTime = startTime;
}

public void setEndTime (Timestamp endTime) {
this.endTime = endTime;
}
// a code that validates the object is in a valid state.
}

First idea:

public class WeeklyAvailabilities {
private TimeRange mondaySlot;
private TimeRange tuesdaySlot;
Private TimeRange Wednesday to Wednesday;
private TimeRange thursdaySlot;
private TimeRange fridaySlot;
private TimeRange saturdaySlot;
private TimeRange sundaySlot;

public WeeklyAvailabilities () {
// set default values
}
// getters and others
public void setMondayStartTime (Start timestamp) {
mondaySlot.setStartTime (start);
}

public void setMondayEndTime (end of timestamp) {
mondaySlot.setEndTime (end);
}
// continue the pattern for all slots
}

Second idea:

public class WeeklyAvailabilities {
private TimeRange mondaySlot;
private TimeRange tuesdaySlot;
Private TimeRange Wednesday to Wednesday;
private TimeRange thursdaySlot;
private TimeRange fridaySlot;
private TimeRange saturdaySlot;
private TimeRange sundaySlot;

public WeeklyAvailabilities () {
// set default values
}
// getters and others
public void setMondaySlot (TimeRange mondaySlot) {
this.mondaySlot = mondayaySlot;
}

// continue the pattern for all slots
}

I am in conflict because the first idea does not require the creation of a new object each time, while the second idea would require something of that kind. Really, I wondered if I could know which one is the best or if there could be a third option that I completely ignore.

python – First solver giving compound numbers

prime numbers =[2]
a = 3
b = 0
while true:
try:
if a first%[b]== 0:
a + = 1
other:
b + = 1
except IndexError:
premiums.append (a)
print a
a + = 2
b = 1

I'm trying to run this code to give me a list of prime numbers, but it spits out numbers such as 16, 27, 95 and other larger compound numbers. The code is executed and no syntax error prevents it from doing so, but it will give me incorrect values ​​and I do not know why. Please let me know if you find any errors or if there is a problem with Python3.