Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1054

Re: Type of element on stack

From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.postscript
Subject Re: Type of element on stack
Organization Decebal Computing
References <87fw4gnafj.fsf@Compaq.site.inet> <agdtriFrm26U1@mid.individual.net> <87pq3ij9ou.fsf@Compaq.site.inet> <k86l65$c3f$1@dont-email.me>
Date 2012-11-17 14:39 +0100
Message-ID <877gpke4cr.fsf@Compaq.site.inet> (permalink)

Show all headers | View raw


Op zaterdag 17 nov 2012 01:19 CET schreef luser droog:

> 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

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

Back to comp.lang.postscript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Type of element on stack Cecil Westerhof <Cecil@decebal.nl> - 2012-11-11 03:24 +0100
  Re: Type of element on stack Dan Coby <adcoby@earthlink.net> - 2012-11-10 21:15 -0800
    Re: Type of element on stack Cecil Westerhof <Cecil@decebal.nl> - 2012-11-11 10:34 +0100
  Re: Type of element on stack Don Lancaster <don@tinaja.com> - 2012-11-12 20:41 -0800
    Re: Type of element on stack Cecil Westerhof <Cecil@decebal.nl> - 2012-11-13 07:31 +0100
      Re: Type of element on stack "luser.droog" <luser.droog@gmail.com> - 2012-11-16 18:19 -0600
        Re: Type of element on stack Cecil Westerhof <Cecil@decebal.nl> - 2012-11-17 14:39 +0100

csiph-web