What is the programming language used in centric PLM expressions - attr

if (leftstr(attr("Node Name"),2) == "SS", rightstr(attr("Node Name"),2) + "A",rightstr(attr("Node Name"),2) + "B")

Related

Manim Equation Transformation

Manim Community v0.15.1
class Equation_Transformation_Bug(Scene):
def construct(self):
equation_1 = MathTex("w", "\\times","v", "=", "1")
equation_1.shift(UP*2).scale(2)
equation_2 = MathTex("v", "=", "w^{-1}")
equation_2.scale(2)
equation_3 = MathTex("w", "\\times","w^{-1}", "=", "1")
equation_3.shift(UP*2).scale(2)
self.play(Write(equation_1), Write(equation_2))
self.wait(2)
self.play(FadeOut(equation_1[2]))
self.play(*[
Transform(
equation_2.get_part_by_tex("w^{-1}"),
equation_3.get_part_by_tex("w^{-1}")
)
] + [
Transform(
equation_1.get_part_by_tex(tex),
equation_3.get_part_by_tex(tex)
)
for tex in ("w", "\\times","=", "1")
])
self.wait(1)
I'm trying to get the w^{-1} from equation_2 to fly into the spot formerly occupied by v of equation_1 and transform into equation_3.
The "1" from equation_1, instead, transforms into the w^{-1} from equation_3.
I'm not trying to do a replacement transform.
How do I transform equation_1 into equation_3 and move the w^{-1} in the spot occupied by "v" of equation_1?
An approach using TransformMatchingShapes works reasonably well in this particular case:
class Eq(Scene):
def construct(self):
equation_1 = MathTex("w", "\\times","v", "=", "1")
equation_1.shift(UP*2).scale(2)
equation_2 = MathTex("v", "=", "w^{-1}")
equation_2.scale(2)
equation_3 = MathTex("w", "\\times","w^{-1}", "=", "1")
equation_3.shift(UP*2).scale(2)
self.play(Write(equation_1), Write(equation_2))
self.wait(2)
self.play(FadeOut(equation_1[2]))
self.play(
TransformMatchingShapes(
VGroup(equation_1[0:2], equation_1[3:], equation_2[2].copy()),
equation_3,
)
)
If you have shapes that would not match uniquely, take a look at the implementation of TransformMatchingShapes, there is a way to tweak what exactly gets transformed into what.

NDsolve problem in set of equations in mathematica

I have written this set of dynamic equations for my problem related to
magnetized targets in fusion. I just want to know why Mathematica
cannot solve it.
I have done this "NDSolve" before and i have taken good answers. but when I change my formulas it cannot solve, what is the problem. I can sendyou the entire code.
`bal = {(3/2)*ne[t]*k*Te'[t] == \[Eta]d*wd + wie - wb +
f\[Alpha]*\[Eta]f*wf - whe, (3/2)*ni[t]*k*
Ti'[t] == (1 - \[Eta]d)*wd - wie + f\[Alpha]*(1 - \[Eta]f)*wf -
whi, nd'[t] = -nd[t]*nT[t]*\[Sigma],
nT'[t] = -nd[t]*nT[t]*\[Sigma],
n\[Alpha]'[t] = nd[t]*nT[t]*\[Sigma], Te[0] = 1, Ti[0] = 1,
nd[0] == nT[0] == \!\(TraditionalForm\`
\*FractionBox[\(1.4447999999999998`*^26\), \(2\)]\), n\[Alpha][0] = 0}
sol = NDSolve[bal, {Te, Ti, nd, nT, n\[Alpha]}, t]
here is the error.
NDSolve::deqn: Equation or list of equations expected instead of -
((2.85474*10^-12 E^(-19.983 ((1<<1>>Plus[<<3>>]<<1>>Power<<1>>
<<1>>])/Ti[t])^(1/3)) nd[t] nT[t])/(Ti[t]^(2/3) (1-(15.136 Ti[t]+4.6064
Ti[<<1>>]^2-0.10675 Ti[<<1>>]^3)/(1000+75.189 Ti[<<1>>]+13.5
Power[<<2>>]+0.01366 Power[<<2>>]))^(5/6))) in the first argument
{4.8*10^-9 nd[t] (Te^\[Prime])[t]==900000000000000000-8.70051*10^-25
(nd[t]+nT[t])^2 Sqrt[Te[t]]-(5.2266*10^46 <<1>>^<<1>> (11.92
+1.69505*10^-9 <<1>>^3))/((nd[t]+nT[t]) (3.77 +<<21>>
<<1>>+1.32084*10^-19 Power[<<2>>]))+(8.7331*10^17 (24-Log[Times[<<4>>]])
nd[t]^2 (-Te[t]+Ti[t]))/(1.09626*10^24 Te[<<1>>]+5.97059*10^20
<<1>>)^(3/2)+(5.152*10^-16 E^(-19.983 Times[<<2>>]^(1/3)) nd[t] nT[t]
(8/3 (4.32916*10^-7+Times[<<3>>])+64/9 Plus[<<2>>]^2))/((1+104/27
Plus[<<2>>]+64/9 Power[<<2>>]) (32+Te[t]) Ti[t]^(2/3) (1-Plus[<<3>>]
Power[<<2>>])^(5/6)),<<7>>,0}.`enter code here`
I change some = to == and I assign values to all the unknown variables and get rid of the TraditionalForm wrapper to turn that into an ordinary fraction
k=1;\[Eta]d=1;wd=1;wie=1;wb=1;f\[Alpha]=1;\[Eta]f=1;wf=1;whe=1;whi=1;\[Sigma]=1;
ne[t_]:=2t+1;ni[t_]:=3t+2;
bal = {(3/2)*ne[t]*k*Te'[t] == \[Eta]d*wd + wie - wb + f\[Alpha]*\[Eta]f*wf - whe,
(3/2)*ni[t]*k*Ti'[t] == (1 - \[Eta]d)*wd - wie + f\[Alpha]*(1 - \[Eta]f)*wf - whi,
nd'[t] == -nd[t]*nT[t]*\[Sigma],
nT'[t] == -nd[t]*nT[t]*\[Sigma],
n\[Alpha]'[t] == nd[t]*nT[t]*\[Sigma],
Te[0] == 1,
Ti[0] == 1,
nd[0] == nT[0] == 1.4447999999999998`*^26/2,
n\[Alpha][0] == 0};
sol = NDSolve[bal, {Te,Ti,nd,nT,n\[Alpha]}, {t,0,1}];
Plot[{Te[t],Ti[t]}/.sol[[1]],{t,0,1}]
Now substitute your actual values for all those variables and your actual functions for ne[t] and ni[t] and see what you get.

How to read variable length application identifiers in .zpl datamatrix in VB6?

According to GS1 standards (http://www.databar-barcode.info/application-identifiers/) a variable length field in a barcode should have a break sign to signal when it ends.
Code for the .zpl printer in my test is as follows:
^BY200,200^FT250,860^BXN,12,200,0,0,6,~
^FH\^FD\7E10012345678912345678910123\7E1151606013712\7E1^FS
This was written according to (http://www.servopack.de/support/zebra/ZPLbasics.pdf) and when I scan it into Notepad++ I see that the breaks are applied in the code as shown in the picture below.
But when I try to scan it in my VB6 application it doesn't appear to catch the break sign and writes everything from 10 (batch number) and forward into the batchnumber instead of breaking before 15 (expiration date).
My code looks like this:
ElseIf Left(Data, 2) = AI_BATCH Or Left(Data, 6) = "<GS>10" Or Left(Data, 3) = "~10" Then
If Left(Data, 2) = AI_BATCH Then
Data = Mid(Data, 3)
ElseIf Left(Data, 6) = "<GS>10" Then
Data = Mid(Data, 7)
ElseIf Left(Data, 3) = "~10" Then
Data = Mid(Data, 4)
End If
' Calculate length
While Mid(Data, AI_BATCH_LEN + 1, 1) <> "" And Mid(Data, AI_BATCH_LEN + 1, 1) <> "~" And Mid(Data, AI_BATCH_LEN + 1, 1) <> "<"
AI_BATCH_LEN = AI_BATCH_LEN + 1
Wend
gs1.batch = Trim(Left(Data, AI_BATCH_LEN))
Data = Mid(Data, 1 + AI_BATCH_LEN)
Thanks in advance.
You seem to be looking for the 2 ASCII characters 'G' and 'S' but you should be looking for the single 'GS' character - GS is ASCII control character 29 (Group Separator).
This character is not printable as a letter so Notepad++ (and the font its using) substitute the graphical glyph you see.
Use chrw$(29) to locate this character:
x = "Hello" & chrw$(29) & "World"
?x
HelloWorld
?left$(x, instr(x, chrw$(29)) - 1)
Hello

Is this a bug on RubyMonk or something flaw in my logic thinking?

I am learning Ruby with Rubymonk.com
Below is the project description:
Hiring Programmers - Boolean Expressions in Ruby
Let us say you are trying to recruit team-members for your new startup! Given a candidate, you need an expression that will tell you whether they fit into certain types. This is how a candidate object would look:
candidate.years_of_experience = 4
candidate.github_points = 293
candidate.languages_worked_with = ['C', 'Ruby', 'Python', 'Clojure']
candidate.applied_recently? = false
candidate.age = 26
We are looking to hire experienced Ruby programmers. Our ideal candidate has 2 or more years of experience, but some programmers become really good even before that. We'll consider their Github points (a nice indicator of a good programmer), and even if they are not experienced, candidates with 500 Github points or more can apply. And there is one more catch: Ruby being a cool and awesome language, a lot of smart youngsters are very good at it. We love those kids, but for this particular job we'd rather have them study at school than work. Let us filter out candidates who are younger than 15. Also we don't want to consider candidates who applied recently for this opening.
Base on above description, I conclude that items listed below must be true:
candidate.languages_worked_with.include?('Ruby')
candidate.years_of_exprience >= 2 || candidate.github_points >= 500
candidate.age > 15
candidate.applied_recently? == false
And my answer is:
is_an_experienced_programmer = (candidate.years_of_exprience >= 2
|| candidate.github_points >= 500) && candidate.languages_worked_with.include? 'Ruby'
&& (candidate.age > 15) && !(candidate.applied_recently?)
but then answer is:
is_an_experienced_ruby_programmer = (candidate.years_of_experience >= 2
|| candidate.github_points >= 500) && (candidate.languages_worked_with.include? 'Ruby')
&& ! (candidate.age < 15 || candidate.applied_recently?)
The only difference between my answer and the answer is:
(candidate.age > 15) && !(candidate.applied_recently?)
above saying candidate must older than 15 and haven't applied recently.
and the answer:
! (candidate.age < 15 || candidate.applied_recently?)
above code basically saying, candidate can not younger than 15 and haven't applied recently.
Aren't they the same? Or something flawed in my logic?
Its almost same only thing you are missing is >=
(candidate.age >= 15) && !(candidate_applied_recently?)
and that's why you might be getting the wrong answer.
Hope it helps.
I conclude that there is something wrong in the Testing Logic with the project on RubyMonk:
When I use the code below, I passed the test:
is_an_experienced_ruby_programmer = (candidate.years_of_experience >= 2 || candidate.github_points >= 500) && (candidate.languages_worked_with.include? 'Ruby') && !candidate.applied_recently? && (candidate.age > 15)
And when I use below, I failed the test:
is_an_experienced_programmer = (candidate.years_of_exprience >= 2 || candidate.github_points >= 500) && (candidate.languages_worked_with.include? 'Ruby') && (candidate.age > 15) && !(candidate.applied_recently?)
So
!(candidate.applied_recently?) && (candidate.age > 15)
is different to
(candidate.age > 15) && !(candidate.applied_recently?)
in Rubymonk's mind?

What other languages have features and/or libraries similar to Perl's format?

I may be in the minority here, but I very much enjoy Perl's formats. I especially like being able to wrap a long piece of text within a column ("~~ ^<<<<<<<<<<<<<<<<" type stuff). Are there any other programming languages that have similar features, or libraries that implement similar features? I am especially interested in any libraries that implement something similar for Ruby, but I'm also curious about any other options.
I seem to recall something similar in Fortran when I used it many years ago (however, it may well have have been a third-party library).
As for other options in Perl, have a look at Perl6::Form.
The form function replaces format in Perl6. Damian Conway in "Perl Best Practices" recommends using Perl6::Form with Perl5 citing the following issues with format....
statically defined
rely on global variables for configuration and pkg variables for data they format on
uses named filehandles (only)
not recursive or re-entrant
Here is a Perl6::Form variation on the Ruby example by Robert Gamble....
use Perl6::Form;
my ( $month, $day, $year ) = qw'Sep 18 2001';
my ( $num, $numb, $location, $toe_size );
for ( "Market", "Home", "Eating Roast Beef", "Having None", "On the way home" ) {
push #$numb, ++$num;
push #$location, $_;
push #$toe_size, $num * 3.5;
}
print form
' Piggy Locations for {>>>}{>>}, {<<<<}',
$month, $day, $year ,
"",
' Number: location toe size',
' --------------------------------------',
'{]}) {[[[[[[[[[[[[[[[} {].0} ',
$numb, $location, $toe_size;
FormatR provides Perl-like formats for Ruby.
Here is an example from the documentation:
require "formatr"
include FormatR
top_ex = <<DOT
Piggy Locations for #<< ##, ####
month, day, year
Number: location toe size
-------------------------------------------
DOT
ex = <<TOD
#) #<<<<<<<<<<<<<<<< ##.##
num, location, toe_size
TOD
body_fmt = Format.new (top_ex, ex)
body_fmt.setPageLength(10)
num = 1
month = "Sep"
day = 18
year = 2001
["Market", "Home", "Eating Roast Beef", "Having None", "On the way home"].each {|location|
toe_size = (num * 3.5)
body_fmt.printFormat(binding)
num += 1
}
Which produces:
Piggy Locations for Sep 18, 2001
Number: location toe size
-------------------------------------------
1) Market 3.50
2) Home 7.00
3) Eating Roast Beef 10.50
4) Having None 14.00
5) On the way home 17.50
There is the Lisp (format ...) function. It supports looping, conditionals, and a whole bunch of other fun stuff.
for example (copied from above link):
(defparameter *english-list*
"~{~#[~;~a~;~a and ~a~:;~#{~a~#[~;, and ~:;, ~]~}~]~}")
(format nil *english-list* '()) ;' ==> ""
(format nil *english-list* '(1)) ;' ==> "1"
(format nil *english-list* '(1 2)) ;' ==> "1 and 2"
(format nil *english-list* '(1 2 3)) ;' ==> "1, 2, and 3"
(format nil *english-list* '(1 2 3 4));' ==> "1, 2, 3, and 4"

Resources