Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Type of element on stack
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Cecil Westerhof  
View profile  
 More options Nov 10 2012, 9:24 pm
Newsgroups: comp.lang.postscript
From: Cecil Westerhof <Ce...@decebal.nl>
Date: Sun, 11 Nov 2012 03:24:48 +0100
Local: Sat, Nov 10 2012 9:24 pm
Subject: Type of element on stack
Is there a way to check for the type of an element on the stack?

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Coby  
View profile  
 More options Nov 11 2012, 12:16 am
Newsgroups: comp.lang.postscript
From: Dan Coby <adc...@earthlink.net>
Date: Sat, 10 Nov 2012 21:15:51 -0800
Local: Sun, Nov 11 2012 12:15 am
Subject: Re: Type of element on stack
On 11/10/2012 6:24 PM, Cecil Westerhof wrote:

> Is there a way to check for the type of an element on the stack?

Yes. The type operator. See page 705 of the PLRM 3rd edition.
All of the operators are listed in the PLRM.

GS>1 type =
integertype
GS>[1] type =
arraytype
GS>(aaa) type =
stringtype


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cecil Westerhof  
View profile  
 More options Nov 11 2012, 5:03 am
Newsgroups: comp.lang.postscript
From: Cecil Westerhof <Ce...@decebal.nl>
Date: Sun, 11 Nov 2012 10:34:13 +0100
Local: Sun, Nov 11 2012 4:34 am
Subject: Re: Type of element on stack
Op zondag 11 nov 2012 06:15 CET schreef Dan Coby:

>> Is there a way to check for the type of an element on the stack?

> Yes. The type operator. See page 705 of the PLRM 3rd edition.
> All of the operators are listed in the PLRM.

> GS>1 type =
> integertype
> GS>[1] type =
> arraytype
> GS>(aaa) type =
> stringtype

Works like a charm. Thanks.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Don Lancaster  
View profile  
 More options Nov 12 2012, 10:41 pm
Newsgroups: comp.lang.postscript
From: Don Lancaster <d...@tinaja.com>
Date: Mon, 12 Nov 2012 20:41:32 -0800
Local: Mon, Nov 12 2012 11:41 pm
Subject: Re: Type of element on stack
On 11/10/2012 6:24 PM, Cecil Westerhof wrote:

> Is there a way to check for the type of an element on the stack?

like dup type ?

--
Many thanks,

Don Lancaster                          voice phone: (928)428-4073
Synergetics   3860 West First Street   Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml   email: d...@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cecil Westerhof  
View profile  
 More options Nov 13 2012, 1:47 am
Newsgroups: comp.lang.postscript
From: Cecil Westerhof <Ce...@decebal.nl>
Date: Tue, 13 Nov 2012 07:31:13 +0100
Local: Tues, Nov 13 2012 1:31 am
Subject: Re: Type of element on stack
Op dinsdag 13 nov 2012 05:41 CET schreef Don Lancaster:

>> Is there a way to check for the type of an element on the stack?

> like dup type ?

Yep.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
luser.droog  
View profile  
 More options Nov 16 2012, 7:19 pm
Newsgroups: comp.lang.postscript
From: "luser.droog" <luser.dr...@gmail.com>
Date: Fri, 16 Nov 2012 18:19:15 -0600
Local: Fri, Nov 16 2012 7:19 pm
Subject: Re: Type of element on stack

Cecil Westerhof wrote:
> Op dinsdag 13 nov 2012 05:41 CET schreef Don Lancaster:

>>> Is there a way to check for the type of an element on the stack?

>> like dup type ?

> Yep.

The next cool bit is 'exec'.
'type' returns an executable name, so you can do type-dispatch with a
dictionary. eg.

/do { %different things to different types
   <<
      /integertype{1 add}
      /booleantype{not}
      /realtype{2 exp}
      /stringtype{cvr 1 add}
   >> 1 index type  % x dict x-type
   2 copy known not {pop/default} if
   get exec % x'

} def

Wait. rats. that doesn't use the 'executable' part.
How about...

/do2 { %coerce input to integer
    <<
       /integertype{}
       /realtype{cvi}
       /booleantype{{1}{0}ifelse}
       /stringtype{cvr round cvi}
    >> begin
    dup type exec
    end

} def

This is used by the = and == operators to operate on multiple types in a
sensible manner (without a nasty shrub of ifelse nonsense).

HTH


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cecil Westerhof  
View profile  
 More options Nov 17 2012, 8:39 am
Newsgroups: comp.lang.postscript
From: Cecil Westerhof <Ce...@decebal.nl>
Date: Sat, 17 Nov 2012 14:39:00 +0100
Subject: Re: Type of element on stack
Op zaterdag 17 nov 2012 01:19 CET schreef luser droog:

I have to look into this, to understand what is happening here, but I
gladly will do so. ;-}

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »