f



printing logical variables as "true" and "false"

I would like to print logical variables as "true" and "false" rather
than just "T" and "F", which is what Fortran WRITE statements do. I can
define functions that convert .true. and .false. to the strings "true"
and "false", but is there some edit descriptor I have overlooked?

0
beliavsky (2213)
11/28/2005 8:11:42 PM
comp.lang.fortran 11941 articles. 2 followers. Post Follow

25 Replies
972 Views

Similar Articles

[PageSpeed] 19

<beliavsky@aol.com> wrote:

> I would like to print logical variables as "true" and "false" rather
> than just "T" and "F", which is what Fortran WRITE statements do. I can
> define functions that convert .true. and .false. to the strings "true"
> and "false", but is there some edit descriptor I have overlooked?

Nope. I don't know of a language-provided shortcut for this. Your
function is a pretty simple one to write, but I don't know a way to
avoid it.

-- 
Richard Maine                     | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov            |       -- Mark Twain
0
nospam47 (9747)
11/28/2005 8:38:40 PM

Richard E Maine wrote:
> <beliavsky@aol.com> wrote:
> 
> 
>>I would like to print logical variables as "true" and "false" rather
>>than just "T" and "F", which is what Fortran WRITE statements do. I can
>>define functions that convert .true. and .false. to the strings "true"
>>and "false", but is there some edit descriptor I have overlooked?
> 
> 
> Nope. I don't know of a language-provided shortcut for this. Your
> function is a pretty simple one to write, but I don't know a way to
> avoid it.
> 
I think the function has already been written.
       print *, merge("true", "false", logical_thingo)

unless I've missed something.

Dick Hendrickson

0
11/28/2005 8:58:15 PM

Dick Hendrickson wrote:

> 
> 
> Richard E Maine wrote:
> 
>> <beliavsky@aol.com> wrote:
>>
>>
>>> I would like to print logical variables as "true" and "false" rather
>>> than just "T" and "F", which is what Fortran WRITE statements do. I can
>>> define functions that convert .true. and .false. to the strings "true"
>>> and "false", but is there some edit descriptor I have overlooked?
>>
>>
>>
>> Nope. I don't know of a language-provided shortcut for this. Your
>> function is a pretty simple one to write, but I don't know a way to
>> avoid it.
>>
> I think the function has already been written.
>       print *, merge("true", "false", logical_thingo)
> 
> unless I've missed something.
> 
> Dick Hendrickson
> 
Good thing I added the "unless I've missed something" ;(,
because I missed something.
It should be
      print *, merge(" true", "false", logical_thingo)
because merge requires it's first two arguments to have the
same type parameters.

Dick Hendrickson

0
11/28/2005 9:01:23 PM
Dick Hendrickson <dick.hendrickson@att.net> wrote:

> I think the function has already been written.
>        print *, merge("true", "false", logical_thingo)
> 
> unless I've missed something.

Except that I'd expect a "user-friendly" version to have a simpler
interface, more along the line of logical_string(logical_thingo). Among
other things, the simpler form has the advantage of not requiring the
user to remember picky things like the padding that you mentioned in
your followup.

The implementation of my logical_thing might well have your merge
incantation as its sole executable line.

-- 
Richard Maine                     | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov            |       -- Mark Twain
0
nospam47 (9747)
11/28/2005 9:08:29 PM
Richard E Maine <nospam@see.signature> wrote:

> The implementation of my logical_thing might well have your merge
> incantation as its sole executable line.

Though on thinking slightly more on it, a more "interesting" version
might be one that returned a "minimum-width" length instead of padding.
Doing that is left as an exercise for the reader, the main part of the
excercise being to make sure to stay within the standard's requirements
for specification expressions. I haven't tried the exercise myself;
shouldn't be too hard, but spec expressions are tricky enough that I
wouldn't be confident of getting it right without pulling out the
standard to check.

I suppose that in f2003 one could just make the function result an
allocatable-length string, but that's too easy.  :-) Sometimes I think
that allocatable-length strings, which were almost an unintended but
welcome side effect of other features, might turn out to be one of the
most popular new things in f2003.

-- 
Richard Maine                     | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov            |       -- Mark Twain
0
nospam47 (9747)
11/28/2005 9:24:48 PM

Richard E Maine wrote:

> Richard E Maine <nospam@see.signature> wrote:
> 
> 
>>The implementation of my logical_thing might well have your merge
>>incantation as its sole executable line.
> 
> 
> Though on thinking slightly more on it, a more "interesting" version
> might be one that returned a "minimum-width" length instead of padding.
> Doing that is left as an exercise for the reader, the main part of the
> excercise being to make sure to stay within the standard's requirements
> for specification expressions. I haven't tried the exercise myself;
> shouldn't be too hard, but spec expressions are tricky enough that I
> wouldn't be confident of getting it right without pulling out the
> standard to check.
> 
> I suppose that in f2003 one could just make the function result an
> allocatable-length string, but that's too easy.  :-) Sometimes I think
> that allocatable-length strings, which were almost an unintended but
> welcome side effect of other features, might turn out to be one of the
> most popular new things in f2003.
> 
Heck, you don't need anything that fancy.  A simple
statement function gives a simple solution (that's probably
what you had in mind as an "exercise for the reader", right 
;) ).  Otherwise you could use a function like notation
and use the f2003 defined output stuff which avoids tricky
spec expressions and allocatable-length strings but lets you
do all kinds of fancy variable width output.

Dick Hendrickson

PS:  It's a pretty slow day here.

0
11/28/2005 10:24:21 PM
"Dick Hendrickson" <dick.hendrickson@att.net> wrote in message
news:psLif.187086$zb5.94880@bgtnsc04-news.ops.worldnet.att.net...

> PS:  It's a pretty slow day here.

Here, too.  I finally got caught up.  But I can't see how
you can do it with a statement function.

module print_assist
   implicit none
   contains
      function print_logical(x)
         logical, intent(in) :: x
         character(merge(4,5,x)) print_logical

         print_logical = merge('true ','false',x)
      end function print_logical
end module print_assist

program test
   use print_assist
   implicit none

    write(*,'(a)') ' .TRUE. = /'//print_logical(.TRUE.)//&
       '/ .FALSE. = /'//print_logical(.FALSE.)//'/'
end program test

-- 
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


0
not_valid (1693)
11/29/2005 12:58:00 AM
Hello
I prefer the function. But another alternative is:

program test
   implicit none
   character(len=3D5), dimension(0:1), parameter :: tf =3D (/'false','true
'/)
   logical a,b

   a =3D .true.
   b =3D .false.

   write(*,*) tf(transfer(a,0)), tf(transfer(b,0))

end program
  =20

N=E9stor Grion

0
ngrion (21)
11/29/2005 3:54:28 AM
Nestor Grion <ngrion@gmail.com> wrote:

>    write(*,*) tf(transfer(a,0)), tf(transfer(b,0))

You appear to be assuming things that the standard quite explicitly does
not guarantee. Specifically, you appear to be assuming that the
compiler's internal representation of .true. and .false. are the same as
the internal representations of the integers 0 and 1. This is *NOT* a
standard-conforming assumption and there have been plenty of compilers
where it was not the case. It might happen to work on a particular
collection of compilers; that might even happen to be most current ones
- I haven't checked. But I sure know that it isn't an assumption
justified by the standard.

-- 
Richard Maine                    | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle           |  -- Mark Twain
0
nospam47 (9747)
11/29/2005 4:01:35 AM
Richard Maine wrote:

> You appear to be assuming things that the standard quite explicitly does
> not guarantee. Specifically, you appear to be assuming that the
> compiler's internal representation of .true. and .false. are the same as
> the internal representations of the integers 0 and 1. This is *NOT* a
> standard-conforming assumption and there have been plenty of compilers
> where it was not the case. It might happen to work on a particular
> collection of compilers; that might even happen to be most current ones
> - I haven't checked. But I sure know that it isn't an assumption
> justified by the standard.

It is 0 and -1 on the TOPS-10 Fortran compiler, and it would also 
convert between logical and integer, such that a logical expression 
would have the value 0 or -1.

-- glen

0
gah (12851)
11/29/2005 4:14:11 AM
Richard Maine wrote:

" ...you appear to be assuming that the compiler's internal
representation of .true. and .false. are the same as  the internal
representations of the integers 0 and 1. This is *NOT* a
standard-conforming assumption... "

OK. I continue learning...

I believe that the conversions (T=3D>1, F=3D>0) are useful and frequent. I
suppose that the correct form is (within an arithmetical expression):

     merge(1,0,logical_var)

Two questions. Why standar does not establish an implicit conversion?
This does not diminish the utility of the logical variables (integers
are used)?=20

Thanks

N=E9stor Grion

0
ngrion (21)
11/29/2005 6:02:28 AM
In article <1h6r61b.1dl9q5f1btrvlsN%nospam@see.signature>,
 nospam@see.signature (Richard Maine) wrote:

> You appear to be assuming things that the standard quite explicitly does
> not guarantee. Specifically, you appear to be assuming that the
> compiler's internal representation of .true. and .false. are the same as
> the internal representations of the integers 0 and 1. This is *NOT* a
> standard-conforming assumption and there have been plenty of compilers
> where it was not the case.

However, in hindsight things would sure have been easier over the 
past 25 years if the standard did specify this kind of mapping.  Or 
if LOGICAL were treated as a 2-value subset of INTEGER.  That way, 
you could use logical variables as, for example, array indices, 
do-loop indices, and so on.

$.02 -Ron Shepard
0
ron-shepard (1197)
11/29/2005 7:03:41 AM
Ron Shepard wrote:
> In article <1h6r61b.1dl9q5f1btrvlsN%nospam@see.signature>,
>  nospam@see.signature (Richard Maine) wrote:
>
> > You appear to be assuming things that the standard quite explicitly does
> > not guarantee. Specifically, you appear to be assuming that the
> > compiler's internal representation of .true. and .false. are the same as
> > the internal representations of the integers 0 and 1. This is *NOT* a
> > standard-conforming assumption and there have been plenty of compilers
> > where it was not the case.
>
> However, in hindsight things would sure have been easier over the
> past 25 years if the standard did specify this kind of mapping.  Or
> if LOGICAL were treated as a 2-value subset of INTEGER.  That way,
> you could use logical variables as, for example, array indices,
> do-loop indices, and so on.
>
> $.02 -Ron Shepard

Whilst this would have advantages, there is are significant downsides:
- some coding errors would not be identified
- there is a problem in situations like:
      INTEGER I
      DO I = 0, 2
         IF ( I ) THEN
How does the compiler treat I=2 ? Does it:
a) Error (involving extra code)
b) Just look at the LSB
c) Something else
- Does I = .TRUE. set the LSB or I=1 ?

Dave Flower

0
DavJFlower (306)
11/29/2005 8:46:18 AM
David Flower schreef:



> Whilst this would have advantages, there is are significant downsides:
> - some coding errors would not be identified
> - there is a problem in situations like:
>       INTEGER I
>       DO I = 0, 2
>          IF ( I ) THEN
> How does the compiler treat I=2 ? Does it:
> a) Error (involving extra code)
> b) Just look at the LSB
> c) Something else
> - Does I = .TRUE. set the LSB or I=1 ?
This you can't know (it's not in the Standard, maybe in the manual)

Anyway, the syntax in this case is
  IF(INTEGER) L1, L2, L3
where L? are statement labels. So you should get a compile error. a)
Alternative:
   IF(BTEST(I, 0))  THEN    ! Maybe ?

[JvO]

> Dave Flower

0
jvo_36 (118)
11/29/2005 10:46:00 AM
Hello
In Matlab:

     F =3D> 0
     T =3D> 1

     0 =3D> F
     else =3D> T

A possible implementation is extending the intrinsic function INT:

     int(logical_var,[kind])


N=E9stor Grion

0
ngrion (21)
11/29/2005 1:59:04 PM
Nestor Grion wrote:
> Hello
> In Matlab:
> 
>      F => 0
>      T => 1
> 
>      0 => F
>      else => T

Slightly off topic, but in IDL:

   F => Zero and even values (e.g. -4, -2, 0, 2, 4, etc)
   T => Odd non zero values (e.g. -3, -1, 1, 3, 5, etc)

(which I can't stand, btw.)

I much prefer the Fortran logicals .true. and .false.  It's quite clear what it means. 0 
and 1 have different meanings in different contexts/languages, e.g. "exit 0" from a Bourne 
shell script is a good result, whereas "exit 1" (or some other integer) flags an error. By 
the logic where F=>0 and T=>1, I would think that "exit 0" == "exit false" and it 
indicates an error. With Fortran I don't have to worry about that.

cheers,

paulv

-- 
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
0
paul.vandelst (1947)
11/29/2005 4:44:35 PM
In article <1133253978.442583.140800@g14g2000cwa.googlegroups.com>,
 "David Flower" <DavJFlower@AOL.COM> wrote:

>       INTEGER I
>       DO I = 0, 2

When I mentioned using logical variables as do-loop variables and 
array indices, I meant something more like

   logical :: i
   integer :: array(.false.,.true.)
   do i = .false, .true.  ! or 0,1 or whatever.
      j = array(i)  ! arbitrary expression
      ...

You can write code that looks sort of like this now, but you have to 
define your own integer TRUE and FALSE values, along with the 
appropriate integer<-->logical mapping functions.  It just seems 
like it would have simplified a lot of code to have standardized 
this back in 1977.

$.02 -Ron Shepard
0
ron-shepard (1197)
11/29/2005 6:00:47 PM
Nestor Grion <ngrion@gmail.com> wrote:
[on the conversion of logical to integer]

>      merge(1,0,logical_var)

That would work.
 
> Two questions. Why standar does not establish an implicit conversion?
> This does not diminish the utility of the logical variables (integers
> are used)? 

Such "why" questions are largely imponderable. Allow me to suggest that
some people (lots of them, even) don't find it obvious that there is any
relationship between logicals and integers. Or, if there is a
relationship, what the "intuitive" one is.

I challenge you (hypothetically, not seriously) to answer with "zero" or
"one" next time some "ordinary person" (us computer geeks are
disqualified) asks you a true or false question. Consider whether they
would find the meaning intuitively obvious. I'd posit that if they
understand the meaning, you accidentally found a computer geek. :-)

Why is false the same as 0 and true the same as 1? Or did I get it
backwards? Why not 1 and 2? This is, after all, Fortran and not C.
Arrays are by default 1-based (and prior to f77, you couldn't even
override that default). Or why not +1 and -1? Oh, I can see some logic
to 0 and 1, but I also see logic to the other choices. In the standards
business, it is important to have enough perspective to see multiple
points of view. (Or failing that, to have other people on the committee
who will point out the other viewpoints even if you fail to see them).

So I'd turn around the question and ask why one would think it natural
to have such a relation between integer and logical, and to have the
standard force same version of the relation on all users? Are you next
going to suggest that, of course, characters are really the same thing
as integers... and that the Fortran standard should specify that all
computers use the same character encoding? Seems pretty comparable to
me.

Realize that as of f90 you *CAN* define such a conversion youself and
have it work just like one that was defined by the language, so that,
for example the assignments

  logical = integer
  integer = logical

will do whatever you want them to.

But those matters aside, I think that the original reasons are actually
simpler to understand than that. The Fortran standard was not written in
an attempt to force particular hardware designs. Quite the opposite, the
Fortran standard was very intentionally written to facilitate writing
portable code that would run on a wide variety of hardware. Certainly in
the early days of Fortran, different hardware architectures had
different internal coding schemes that were more natural and efficient.
requiring particular choices of internal representation for logicals
would have caused performance penalties on some hardware. Performance
has traditionally been a significant issue in Fortran.

-- 
Richard Maine                     | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov            |       -- Mark Twain
0
nospam47 (9747)
11/29/2005 6:44:07 PM
"Paul Van Delst" <Paul.vanDelst@noaa.gov> wrote in message
news:dmi229$1on$1@news.nems.noaa.gov...

> Slightly off topic, but in IDL:

>    F => Zero and even values (e.g. -4, -2, 0, 2, 4, etc)
>    T => Odd non zero values (e.g. -3, -1, 1, 3, 5, etc)

> (which I can't stand, btw.)

Actually, the DEC family of Fortran compilers did this, too.
The massive advantage of the LSB defining LOGICAL values like
this is that bitwise logical operations have the effect of
Fortran LOGICAL operations.  I consider it probable that
many old-school compilers (i.e. ones that have roots predating
MIL-STD 1753) behave this way so as to permit masking
expressions.  The difference in behavior becomes apparent
when mixed-language programming of bit-swizzling via
TRANSFER.  One can get ugly results when Fortran processors
use the C-style (value of x is "x /= 0") int as boolean:
you can have both a and b evaluate as .TRUE., but a .AND. b
evaluate as .FALSE.

program logical_test
   implicit none
   logical a, b

   a = transfer(1,a)
   b = transfer(2,b)
   write(*,*) a, b, a .AND. b
end program logical_test

Output with LF95 v. 5.70f:

T T F

Output with CVF v. 6.6C3

 T F F

Output with g95 gcc version 4.0.1 (g95!) Sep  1 2005:

 T T T

-- 
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


0
not_valid (1693)
11/29/2005 6:47:11 PM
In article <WqadnVLsSpFkPBHenZ2dnUVZ_tmdnZ2d@comcast.com>,
James Van Buskirk <not_valid@comcast.net> wrote:
>
>-- 
>write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
>6.0134700243160014d-154/),(/'x'/)); end


Are you aware that running the Fortran program in your signature
produces different results with various compilers?

Intel Fortran 8.0 on Fedora Core 4:
 rjihad1@comcast.net

Sun Fortran on Solaris:
 @1dahijr.tsacmoc     ten

XLF on IBM RS/6000:
 @1dahijr��ʼl0�a.tsacmoc*Ӱ[���     ten`~�

MIPSpro f90 on SGI:
 @1dahijr.tsacmoc     ten

Compaq f90 on Compaq SC45:
 rjihad1@comcast.net

Andy
0
mai (5)
11/29/2005 9:43:13 PM
"Andy Mai" <mai@meeker.ucar.edu> wrote in message
news:dmii1h$pq6$1@meeker.ucar.edu...

> Are you aware that running the Fortran program in your signature
> produces different results with various compilers?

I may have to change my email address and not include it
in my sig.f90 file because you printed it in public.  Thanks
a lot.

-- 
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


0
not_valid (1693)
11/29/2005 11:12:29 PM
On Mon, 28 Nov 2005 21:01:23 GMT, Dick Hendrickson
<dick.hendrickson@att.net> wrote:

>Dick Hendrickson wrote:

>> I think the function has already been written.
>>       print *, merge("true", "false", logical_thingo)
>> 
>> unless I've missed something.

>Good thing I added the "unless I've missed something" ;(,
>because I missed something.
>It should be
>      print *, merge(" true", "false", logical_thingo)
>because merge requires it's first two arguments to have the
>same type parameters.

<copies and pastes both>

print *, merge("true", "false", logical_thingo)
print *, merge(" true", "false", logical_thingo)

No, my eyes don't deceive me, the only difference is a leading space
in " true". I've never used merge, but it seems /I've/ missed
something. Aren't "true" and " true" the same type?
0
11/30/2005 11:00:49 AM
Hello,

Andy Spragg wrote:

<snip>

> print *, merge("true", "false", logical_thingo)
> print *, merge(" true", "false", logical_thingo)
> 
> No, my eyes don't deceive me, the only difference is a leading space
> in " true". I've never used merge, but it seems /I've/ missed
> something. Aren't "true" and " true" the same type?

They both have the same type (character) and
the same type kind parameter value (default).
They differ in type length parameter value (4 v. 5).

-- 
Cheers!

Dan Nagle
Purple Sage Computing Solutions, Inc.
0
dannagle (1018)
11/30/2005 11:35:47 AM
>>Slightly off topic, but in IDL:
> 
>>   F => Zero and even values (e.g. -4, -2, 0, 2, 4, etc)
>>   T => Odd non zero values (e.g. -3, -1, 1, 3, 5, etc)
> 
>>(which I can't stand, btw.)
> Actually, the DEC family of Fortran compilers did this, too.

....which, I believe, is no conincidence as IDL was "born" on VMS, IIRC.

	Jan
0
12/8/2005 11:13:37 AM
> Are you aware that running the Fortran program in your signature
> produces different results with various compilers?

That's the difference between little- and big-endian machines, with
an uninitialized string on the IBM thrown in for good measure.

	Jan
0
12/8/2005 11:15:43 AM
Reply:

Similar Artilces:

""""""""""""""""""""""ADD ME""""""""""""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfo 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... We look forward to build a ve...

"""""""""ADD ME""""""""""
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 ...

about "++" and "--"
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...

"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...

"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...

"/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" >>>&...

"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...

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....

Urgent Requirement for """""""""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting ...

Urgent need """""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting Database/ETL requirements (Optional) Data warehousing experience Threading and job concepts in 10g/11g Cost based Optimizer concepts in 10g/11g Must : Experience with XML files and partitioning concepts in Oracle, Collections, Material Views Note : No phone calls please. : send Resumes to karthik@bhaninfo.com Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com ...

"==" is NOT TRUE "==", WHY?
[CODE START] x=5; y=8; if (x + y + 1E-15 == 13) a = 3 else a = 8 end [CODE END] When x + y + 1E-15, the code above returns a = 8. When x + y + 1E-16, the code above returns a = 3. Why? Kindly advise. Thanks. "onemilimeter Chen" <onemm@example.com> wrote in message <g7adrj$5tr$1@fred.mathworks.com>... > [CODE START] > x=5; > y=8; > if (x + y + 1E-15 == 13) > a = 3 > else > a = 8 > end > [CODE END] > > When x + y + 1E-15, the code above returns a = 8. > When x + y + 1E-16, the code above returns a = 3. > > Why? ...

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\.....

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) ...

"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 ...

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...

[Hibernate] yes_no property being mapped as "true"/"false" instead of "Y"/"N" ??
From the log: Hibernate: /* insert collection row com.wholefoods.ittoolkit.ws.ccf.Request.assets */ insert into ITTOOLKIT.CR_ASSET (REQ_ID, ASSET_ENTRY_ID, NAGIOS_DOWNTIME, REBOOT, SYSTEM_TYPE_ID, OS_TYPE_ID) values (?, ?, ?, ?, ?, ?) 12:15:26,546 DEBUG org.hibernate.jdbc.AbstractBatcher:476 - preparing statement 12:15:26,562 DEBUG org.hibernate.type.LongType:133 - binding '41' to parameter: 1 12:15:26,562 DEBUG org.hibernate.type.StringType:126 - binding null to parameter: 2 12:15:26,562 DEBUG org.hibernate.type.YesNoType:133 - binding 'true' to parameter: 3 12:15:26,577 DEBUG org.hibernate.type.YesNoType:133 - binding 'false' to parameter: 4 12:15:26,577 DEBUG org.hibernate.engine.IdentifierValue:77 - id unsaved-value strategy UNDEFINED 12:15:26,577 DEBUG org.hibernate.type.StringType:133 - binding 'PRD' to parameter: 5 12:15:26,577 DEBUG org.hibernate.engine.IdentifierValue:77 - id unsaved-value strategy UNDEFINED 12:15:26,577 DEBUG org.hibernate.type.StringType:133 - binding 'Windows' to parameter: 6 The database column is defined as CHAR(1), so of course binding 'true' or 'false' fails with "value too large". Everything I can find on the web and in JPE about type="yes_no" indicates it will be mapped as "Y" and "N", not "true" and "false". Is this a bug? Here's the corresponding mapping: <bag name="assets&q...

Gary Sokolich """"""
"""""""""" http://www.manta.com/c/mmlq5dm/w-gary-sokolich W Gary Sokolich 801 Kings Road Newport Beach, CA 92663-5715 (949) 650-5379 http://www.tbpe.state.tx.us/da/da022808.htm TEXAS BOARD OF PROFESSIONAL ENGINEERS February 28, 2008 Board Meeting Disciplinary Actions W. Gary Sokolich , Newport Beach, California �V File B-29812 - It was alleged that Dr. Sokolich unlawfully offered or attempted to practice engineering in Texas (...) Dr. Sokolich chose to end the proceedings by signing a Consent Order that was accepted by ...

puts "\\".gsub("\\", "\\\\")
Hello, I have a mini-ruby quiz. Guess what this line of code writes to the console, then try it for yourself: puts "\\".gsub("\\", "\\\\") Why is that so? Martin From: martinus [mailto:martin.ankerl@gmail.com]=20 # Hello, I have a mini-ruby quiz. Guess what this line of code writes to # the console, then try it for yourself: # puts "\\".gsub("\\", "\\\\") puts "\\".gsub("\\", "\\\\") \ #=3D> nil # Why is that so? faq. escaping the escape in sub/gsub. search the archives. maybe you want somethin...

Question about "sprintf" "@" "do for"
Hello, this works: A1=3D1 A2=3D2 A3=3D3 i=3D1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari do for [i=3D1:3]{ vari=3Dsprintf("A%.f",i) print vari } But I want to have "print vari,"=3D",@vari" in the loop. But it dosen't=20 work. Why can't I use "print vari,"=3D",@vari" in the loop? Is there a=20 solution for? J=C3=B6rg Jörg ...

Why Turn "Print" into "Print()"????
Hi, your friendly neighborhood n00b here, just wondering why on earth the Py3K folks want to mess with a simple thing like the "print" "command" (is that what it's called, a command?), turning it into "print()"...I mean, what's the point, exactly?? To look like a more "traditional" computer-language format? And what's with not supporting the so-called softspace "feature" of the current "print" command, where a space after a comma, like >>>print "A\n", "B" outputs >>>A\nB\n but w...

How to "print" a "double" ?
Hi folks, This question seems a bit funny, but is there a way to "serialize" a C-"double" ("binary64" as per IEEE 754) number using a standard format (printf..) keeping the maximum precision possible (ie. limiting the precision loss after the two sprintf()/sscanf() operations) ? IEEE 754 64-bit numbers have a precision (p) of 52 bits, hence a maximum of 16 digits after the dot are normally to be expected. But this is too much if the exponent is non-zero. Ie. "%.16lf" will produce "0.3333333333333333" for 1/3, and "333.3333333333333144" for 1000/3, or even "1.0000000000000000" for 1. The second and third examples have spurious or useless digits. If there is no other way, I suppose that "%.16lf" is the lesser evil, but definitely not a clean solution. [ Another way would be to treat the IEEE 754 64-bit number as a regular 64-bit integer (using some union magic), but this is definitely not something I would use ] On March 31, 2009 09:26, in comp.unix.programmer, Xavier Roche (xroche@free.fr.NOSPAM.invalid) wrote: > Hi folks, > > This question seems a bit funny, but is there a way to "serialize" a > C-"double" ("binary64" as per IEEE 754) number using a standard format > (printf..) keeping the maximum precision possible (ie. limiting the > precision loss after the two sprintf()/sscanf() operations) ? If you don't /require/ a human-r...

a variable "a" and "window.a" ??
i saw a code refactorying onload event listener window.onloadListeners=new Array(); window.addOnLoadListener=function(listener) { window.onloadListeners[window.onloadListeners.length]=listener; } why declare the onloadListeners, addOnLoadListener below window? i think bare "afunc" and "window.afunc" are same thing and available both way. is there a difference? On Jan 26, 12:51 pm, "gg9h0st" <mn9h...@hotmail.com> wrote: > i saw a code refactorying onload event listener > > window.onloadListeners=new Array(); > window.addOnLoadListener=f...

Web resources about - printing logical variables as "true" and "false" - comp.lang.fortran

Resources last updated: 3/8/2016 4:05:25 AM