f

#### In Metapost, What's the difference between "=" and ":="?

```Hi,

I don't see explanation about the difference between "=" and ":=" in
Metapost?

Do you know what's the difference?

Thanks,
Peng
```
 0
pengyu.ut (763)
11/19/2004 4:07:21 PM
comp.text.tex 39029 articles. 3 followers.

6 Replies
790 Views

Similar Articles

[PageSpeed] 33

```Peng Yu <pengyu.ut@gmail.com> writes:

> Hi,
>
> I don't see explanation about the difference between "=" and ":=" in
> Metapost?
>
> Do you know what's the difference?

:= is an assignment: "go put that value in there right now", = is just
another constraint that will be solved: "go find a solution that
satisfies this constraint." Of course, with "a=3cm", there's not many
values that will work for a.

Consider

a = 3cm; a := 4cm;

If the second assignment were just an equation, mpost would complain
that 3cm does not equal 4cm, because you're saying you want a to be
3cm and 4cm at the same time.

HTH
Ulrich
--
Getting lost in the \footnotes and \temporals? Talcum makes LaTeX more fun.
Now with whole new bugs ;), and, of course, still with special Beamer support.
http://talcum.sarovar.org/  (Current release: 0.4.3)
```
 0
brotherelf (665)
11/19/2004 4:41:12 PM
```Peng Yu <pengyu.ut@gmail.com> writes:

> I don't see explanation about the difference between "=" and ":=" in
> Metapost?
>
> Do you know what's the difference?

The METAFONT-book (among others) explains this.

:= is just the ordinary assignment of most programming languages: it
unbinds the variable at the left side, calculates the value at the
right side and then assigns it to the variable at the left side.

In contrast, = introduces an equation.  I can write

a+b = 0;

which is equivalent to

0 = a+b;

I can't use := in those instances.  Equations are additive.  While I can
write
a := 0;
a := 1;

it is not allowed to write

a = 0;
a = 1;

--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
UKTUG FAQ: <URL:http://www.tex.ac.uk/cgi-bin/texfaq2html>
```
 0
dak (3569)
11/19/2004 4:48:39 PM
```Peng Yu <pengyu.ut@gmail.com> wrote:

> I don't see explanation about the difference between "=" and ":=" in
> Metapost?
>
> Do you know what's the difference?

"=" is for equations, ":=" is for assignments. For example,
"a:=a+1" is legal and increases by 1 the value of a, while
"a=a+1" is illegal and raises an error.

See page 9 of the Metapost manual.

Ciao
Enrico
```
 0
gregorio (1367)
11/19/2004 5:07:03 PM
```On Fri, 19 Nov 2004 10:07:21 -0600, Peng Yu <pengyu.ut@gmail.com> wrote:

>Hi,
>
>I don't see explanation about the difference between "=" and ":=" in
>Metapost?
>
>Do you know what's the difference?

That is covered in the Metafont book (the two programs share the
same programming language.

In MP you can say

x1 + x2 = 1;
x1 - x2 = 0;

and MP will calculate that x1=.5, and x2=.5. MP will also remember
the relationship between x1 and x2 and will complain if you say

x1 = 3;

But if you say

x1 := 3;

then x1 will have the value 3, x2 will remain equal to .5, but the
relationships involving x1 wil be forgotten.

Thus := is the assignment operator, whereas = states a relatonship.

There are other uses of = where := will not substitute:
1) It is a boolean operator,
2) it is part of the syntax for "for loops".

The = that introduces the replacement text of a definition can be
replaced with :=.

Dan

--
Dan Luecking                     Department of Mathematical Sciences
University of Arkansas           Fayetteville, Arkansas 72701
To reply by email, change Look-In-Sig to luecking
```
 0
Look-In-Sig (1094)
11/19/2004 9:08:06 PM
```Dan Luecking <Look-In-Sig@uark.edu> writes:

> There are other uses of = where := will not substitute:
> 1) It is a boolean operator,
> 2) it is part of the syntax for "for loops".

You are wrong about 2).  Either may be used in a for loop.
From the MF book, p. 171

<loop header> --> for <symbolic token><is><for list>

<is> --> = | :=

And more to the point, last line same page:

"As in macro definitions, '=' and ':=' are interchangeable here."

Joe
```
 0
joer343 (33)
11/22/2004 2:44:20 AM
```On Mon, 22 Nov 2004 02:44:20 GMT, Joe Riel <joer@k-online.com> wrote:

>Dan Luecking <Look-In-Sig@uark.edu> writes:
>
>> There are other uses of = where := will not substitute:
>> 1) It is a boolean operator,
>> 2) it is part of the syntax for "for loops".
>
>You are wrong about 2).  Either may be used in a for loop.
>From the MF book, p. 171
>
><loop header> --> for <symbolic token><is><for list>
>
><is> --> = | :=

Sorry, memory failure. I thought I remembered a problem with
for loops, but apparently not.

Dan

--
Dan Luecking                     Department of Mathematical Sciences
University of Arkansas           Fayetteville, Arkansas 72701
To reply by email, change Look-In-Sig to luecking
```
 0
Look-In-Sig (1094)
11/22/2004 5:14:32 PM

Similar Artilces:

Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

Urgent Requirement in """""""""""""NEW YORK""""""""""""""""
Hello Partners, Please find the requirement below. Please send the updated resume along with rate and contact no. REQ#1: Title : Java Developer ( Rating Project) Duration : 6 months Rate : open Location : NY strong java, WebLogic 9.2, Web Services, Oracle REQ#2: Title : Java Developer Duration : 4 months Rate : open Location : NY Strong java, SQL REQ#3: Title : VB.Net Consultant Location : NY Duration : 4 months Rate : open Primarily looking at someone who has Excel, VB.net and Oracle (good to have). Req #4: Title : Java Developer (MSA Project) Duration : 6+ months Rate : open Location : NY Note : Please send your updated resume along with contact no karthik@bhaninfo.com : No phone calls please. Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com ...

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

"or" and "and"
Hi, I'm just getting to discover ruby, but I find it very nice programming language. I just still don't understand how the "or" and "and" in ruby... I was playing with ruby and for example made a def to print Stem and Leaf plot (for those who didn't have a statistics course or slept on it, e.g. http://cnx.org/content/m10157/latest/) Here is the Beta version of it: class Array def n ; self.size ; end def stem_and_leaf(st = 1) # if st != (2 or 5 or 10) then ; st = 1 ; end k = Hash.new(0) self.each {|x| k[x.to_f] += 1 } k = k.sort{|a, b| a[0].to_f <=&g...

"my" and "our"
Hi, while testing a program, I erroneously declared the same variable twice within a block, the first time with "my", the second time with "our": { my \$fz = 'VTX_Link'; .... ( around 200 lines of code, all in the same block) our \$fz = 'VTX_Linkset'; ... } So the initial contents of the \$fz declared with "my" is lost, because "our" creates a lexical alias for the global \$fz, thus overwriting the previous "my" declaration. It was my error, no question. But I wonder why Perl doesn't mention this - even with "use s...

"If then; if then;" and "If then; if;"
I have a raw data set which is a hierarchical file: H 321 s. main st P Mary E 21 F P william m 23 M P Susan K 3 F H 324 S. Main St I use the folowing code to read the data to creat one observation per detail(P) record including hearder record(H): data test; infile 'C:\Documents and Settings\retain.txt'; retain Address; input type \$1. @; if type='H' then input @3 Address \$12.; if type='P' then input @3 Name \$10. @13 Age 3. @16 Gender \$1.; run; but the output is not what I want: 1 321 s. main H 2 321 s. main P Mary E 21 F 3 321 s...

why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

"/a" is not "/a" ?
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # eeeeek! Why c and d point to two different objects with an identical string content rather than the same object? Manu Emanuele D'Arrigo wrote: >>>> c = "/a" >>>&...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

Does it need a ";" at the very after of "if" and "for"
write code like: int main(void) { int a=10; if(a<20) {} } Compiler ok on dev-cpp . don't we have to add a ";" after if statement? marsarden said: > write code like: > > int main(void) > { > int a=10; > if(a<20) > {} > } > > Compiler ok on dev-cpp . don't we have to add a ";" after if > statement? The syntax for 'if' is: if(expression) statement There is no semicolon after the ) but before the statement. The statement is either a normal statement (which can be empty), ending in a semicolon:- if(expr) ...

A problem about "[ ]" "( )" "="
I want to read several images saved in a director,and give them to I1,I2 ,I3....,using the following codes: filelist=dir(['c:\MATLAB701\work\...\*.jpg']); for i=1 :length(filelist) I=imread(fullfile('c:\MATLAB701\work\...',filelist(i).name)); end; but failed. Then I used I(i)=imread... ,still failed. How could I do? "John" <mailofww@126.com> wrote in message news:ef19e12.-1@webx.raydaftYaTP... >I want to read several images saved in a director,and give them to > I1,I2 ,I3....,using the following codes: > filelist=dir(['c:\MATLAB701\work\.....

"In" "Out" and "Trash"
I just bought a new computer and I re-installed Eudora Light on my new computer. But when I open Eudora, the "In", "Out" and "Trash" links are not on the left side of the screen the way they were on my old computer. How can I get these links back on the left side of the screen? Thank you. On 25 Mar 2007 09:49:22 -0700, "abx" <abfunex@yahoo.com> wrote: >I just bought a new computer and I re-installed Eudora Light on my new >computer. But when I open Eudora, the "In", "Out" and "Trash" links >are ...

Dijkstra's "Enumeration" = "Metrics" his "Abstraction" = "Quality"
"Enumerative reasoning is only an adequate mental tool under the severe boundary condition that we only use it very moderately. We should appreciate abstraction as our main mental technique to reduce the demands made upon enumerative reasoning." ~ EW Dijkstra This is critically decisive because Dijkstra is saying that in most *software engineering" contexts, most of the time, abstraction is key relative to "metrics", the numerical, the quantitative. It is a TOWWWEEERRRING, grand slam "home run". It is of Doug William's 3-4 perfectly pitched Super Bowl touchdowns. It is growth in insight after Dijkstra one of THE very best ran into major impasses attempting to drive development with metrics. His insight is that ABSTRACTION should "lead" the way. While there is the dialectic: metrics<=>abstraction The predominant factor to engage and lead software engineering by is "abstraction". So notation wise better: metrics<=>abstraction* And to denote analyzing or summarizing the dialectic applied in whatever context, from point 'a' to 'b': a,b{ metrics<=>abstraction* Discrete points: a,b; l,q{ metrics<=>abstraction* Have at your own meaningful fun! Elliott -- Global Plans + IID = part of an optimal approach On Wed, 4 Feb 2004 23:36:17 -0500, "Universe" <universe@tAkEcovadOuT.net> wrote: >"Enumerative reasoning is only an adequate mental tool und...

What's the difference between "JDK" and "JRE"?
It seems both have a java.exe which can be used to execute the byte code(.class) but then jre does not have the javac compiler. broli wrote: > It seems both have a java.exe which can be used to execute the byte > code(.class) but then jre does not have the javac compiler. You basically answered your own question. -- Sabine Dinis Blochberger Op3racional www.op3racional.eu broli wrote: > It seems both have a java.exe which can be used to execute the byte > code(.class) but then jre does not have the javac compiler. Google is your friend http://www.google.com/search?q=jre+jdk+di...

what's the difference of "image" and "imshow"
Hello, All! as showed in title. when i execute the following script: i=imread('moon.tif'); image(i); %it don't show picture correctly however,if i use "imshow(i)",then it works Thanks for repling antique. E-mail: ck21007@sohu.com antique wrote: > Hello, All! > > as showed in title. > when i execute the following script: > i=imread('moon.tif'); > image(i); %it don't show picture correctly > > however,if i use "imshow(i)",then it works Check you current colormap: image(i) colormap(gray(256)); should give identica...

What's the difference between "labels" and "defun"
What's the difference between them? (defun count-instances(obj lsts) (labels ((instances-in (lst) (if (consp lst) (+ (if (eq (car lst) obj) 1 0) (instances-in (cdr lst))) 0))) (mapcar #'instances-in lsts))) (defun count-instances1 (obj lsts) (defun instances-in (lst) (if (consp lst) (+ (if (eq (car lst) obj) 1 0) (instances-in (cdr lst))) 0)) (mapcar #'instances-in lsts)) (count-instances 'a '((a b c) (d a r p a) (d a r) (a a))) (count-instances1 'a '((a b c) (d a r p a) (d a r) (a a))) I got the same result (1 2 1...

what's difference between "changed" and "modified"?
I'm studying the find command, but feel puzzled on the c... and m.... Could anyone give me a brief decription? I had believed that for file they were the same... Thank you very much! On Tue, 16 Sep 2008 23:08:27 -0700 (PDT), "wyhang@gmail.com" <wyhang@gmail.com> wrote: >I'm studying the find command, but feel puzzled on the c... and m.... >Could anyone give me a brief decription? I had believed that for file >they were the same... I think you'll find one is the file, the other is the directory entry. Grant. -- http://bugsplatter.id.au/ On 2008-09-17,...

What's the difference between "Newsgroup" and "Answers"?
This might be a dumb question, but what is the difference between "Matlab Answers" and "Matlab Newsgroup"? I have always used Newsgroup whenever I needed the answer to a question or help with some code, and Answers is new to me (maybe I've been off the site for a while). Is "Answers" just a new attempt at being more social-network-y and creating something like Yahoo Answers? Are the two things redundant? Is it worth cross-posting a question in both locations? Or is that discouraged? At first glance it seems redundant and confusing to have Answers and Newsg...

(mapcar 'quote '("1" "2" "3" "4"))
(mapcar 'quote '("1" "2" "3" "4")) returns ((quote "4") (quote "4") (quote "4") (quote "4")) Interesting and (for me) unexpected. Because (mapcar 'read '("1" "2" "3" "4")) returns (1 2 3 4) and (mapcar 'princ '("1" "2" "3" "4")) gives 1234("1" "2" "3" "4") Why isn't (mapcar 'quote '("1" "2" "3" "4")) returning ((quote "1") (quote "2") (quote "3") (quote "4")) Tom Haws www.hawsedc.com Probably has to do with the fact that 'arg and (quote arg) are equivalent, and LISP gets confused by the construct 'quote, which is about the same as (quote (quote arg)). But I don't pretend to know all of the mechanics of the error; the results are somewhat different in R14, BTW: Command: (mapcar 'quote '("1" "2" "3" "4")) ((<Subr: #22e3e40> "4") (<Subr: #22e3e40> "4") (<Subr: #22e3e40> "4") (<Subr: #22e3e40> "4")) ___ "Tom Haws" <hawstom@despammed.com> wrote in message news:77317472.0309160733.45ea9d8c@posting.google.com... > (mapcar 'quote '("1" "2" "3"...

In xml schema, what's the difference between attribute "final" and "block" in element "element"
That is, what's the difference between <complexType name="Address" final="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <element name="city" type="string"/> </sequence> </complexType> and <complexType name="Address" block="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type=&qu...

Urgent JAVA Requirement in """"""NEW YORK"""""""""
Hello Partners, How are you ? Please find the requirement below. Location : NY Duration : 8 mnths Rate :Open Job description: Java/J2EE Web Service Developer =B7 (4+ years of application development experience in Java/J2EE and Web service technologies. =B7 Experience with spring & Hibernate. =B7 Experience with J2EE Application Server (preferably Web logic). =B7 Preferable Aqua logic DSP Experience =B7 Preferable Sonic ESB Composite Service experience Experience w...

Old: Microsoft's PR "Spooks"/"Spies"/"Owners"/"Buddies"
Microsoft Critics Assigned PR "Spooks" ,----[ Quote ] | San Jose Mercury technology reporter Dan Gilmore recently discovered he's | been assigned a special "owner" at one of Microsoft's public relations firms, | Waggener-Edstrom. These spin-masters are attached to troublesome journalists | like Gilmore who have the temerity to write uncomplimentary articles about | the company or its products. | | The really irksome reporters, according to documents spirited from the | Waggener-Edstrom offices, are also assigned "buddies" at Microsoft itself. |...