[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

parsing SCREAMER real values

Mirko

4/1/2015 5:49:00 PM

Hello,

I am using SCREAMER and could not figure out how to deal with real's

Consider the following code in the SCREAMER-USER package
(defun f<->c (&key f c)
"Converter between degree Fahrenheit and Celsius

Only one key should be specified.

If both keys are specified, the results are undefined"
(let ((vf (a-realv 'f))
(vc (a-realv 'c)))
(when f (assert! (=v vf f)))
(when c (assert! (=v vc c)))
(assert! (=v vf (+v (*v 9/5 vc) 32)))
(list vf vc)))

I get:
SCREAMER-USER> (f<->c :f 32)
([F real 32:32] [C real 0:0])

I would like to extract the numerical values.

In the documentation I did not see a public method how to extract the
range limits. I can use slot-value, but the slot name is not exported.
Is there (there must be) a better way. I must be missing something.

Thanks,

Mirko

PS - I did post on the screamer user group, but got no reply.
4 Answers

Pascal J. Bourguignon

4/1/2015 7:52:00 PM

0

Mirko Vukovic <mirko.vukovic@gmail.com> writes:

> Hello,
>
> I am using SCREAMER and could not figure out how to deal with real's
>
> Consider the following code in the SCREAMER-USER package
> (defun f<->c (&key f c)
> "Converter between degree Fahrenheit and Celsius
>
> Only one key should be specified.
>
> If both keys are specified, the results are undefined"
> (let ((vf (a-realv 'f))
> (vc (a-realv 'c)))
> (when f (assert! (=v vf f)))
> (when c (assert! (=v vc c)))
> (assert! (=v vf (+v (*v 9/5 vc) 32)))
> (list vf vc)))
>
> I get:
> SCREAMER-USER> (f<->c :f 32)
> ([F real 32:32] [C real 0:0])
>
> I would like to extract the numerical values.

The values are already bound to f and c. Why do you want to extract
them out of vf and vc?

Otherwise, there's a value-of function in screamer, but
(value-of (first (f<->c :f 42))) --> [f real 42:42]
so I'm not sure that's what you want.


> In the documentation I did not see a public method how to extract the
> range limits. I can use slot-value, but the slot name is not exported.
> Is there (there must be) a better way. I must be missing something.

Don't use slot-value, but I guess you could use:
screamer::variable-lower-bound and
screamer::variable-upper-bound.

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

William James

4/1/2015 8:00:00 PM

0

Mirko Vukovic wrote:

> Hello,
>
> I am using SCREAMER and could not figure out how to deal with real's
>
> Consider the following code in the SCREAMER-USER package
> (defun f<->c (&key f c)
> "Converter between degree Fahrenheit and Celsius
>
> Only one key should be specified.
>
> If both keys are specified, the results are undefined"
> (let ((vf (a-realv 'f))
> (vc (a-realv 'c)))
> (when f (assert! (=v vf f)))
> (when c (assert! (=v vc c)))
> (assert! (=v vf (+v (*v 9/5 vc) 32)))
> (list vf vc)))
>
> I get:
> SCREAMER-USER> (f<->c :f 32)
> ([F real 32:32] [C real 0:0])
>
> I would like to extract the numerical values.

1. That function contains the formula for converting Celsius
to Fahrenheit; it doesn't contain the formula for converting
Fahrenheit to Celsius.

2. Who used tabs in that code?

Gauche Scheme:

(define (f<->c :key f c)
(when (undefined? c) (set! c (*. (- f 32) 5/9)))
(when (undefined? f) (set! f (+. (* 9/5 c) 32)))
(map cons '(F C) (list f c)))

Mirko

4/1/2015 8:27:00 PM

0

On Wednesday, April 1, 2015 at 4:00:31 PM UTC-4, WJ wrote:
> Mirko Vukovic wrote:
>
> > Hello,
> >
> > I am using SCREAMER and could not figure out how to deal with real's
> >
> > Consider the following code in the SCREAMER-USER package
> > (defun f<->c (&key f c)
> > "Converter between degree Fahrenheit and Celsius
> >
> > Only one key should be specified.
> >
> > If both keys are specified, the results are undefined"
> > (let ((vf (a-realv 'f))
> > (vc (a-realv 'c)))
> > (when f (assert! (=v vf f)))
> > (when c (assert! (=v vc c)))
> > (assert! (=v vf (+v (*v 9/5 vc) 32)))
> > (list vf vc)))
> >
> > I get:
> > SCREAMER-USER> (f<->c :f 32)
> > ([F real 32:32] [C real 0:0])
> >
> > I would like to extract the numerical values.
>
> 1. That function contains the formula for converting Celsius
> to Fahrenheit; it doesn't contain the formula for converting
> Fahrenheit to Celsius.

Sorry, I was not clear. The screamer code is declarative, not
procedural. Thus the =v, /v, *v, +v.

The *same* code (in screamer gives the following results
SCREAMER-USER> (f<->c :c 100)
([F real 212:212] [C real 100:100])
SCREAMER-USER> (f<->c :f 212)
([F real 212:212] [C real 100:100])
SCREAMER-USER>

Mirko

4/1/2015 8:30:00 PM

0

On Wednesday, April 1, 2015 at 3:59:50 PM UTC-4, informatimago wrote:
> Mirko Vukovic <mirko.vukovic@gmail.com> writes:
>
> > Hello,
> >
> > I am using SCREAMER and could not figure out how to deal with real's
> >
> > Consider the following code in the SCREAMER-USER package
> > (defun f<->c (&key f c)
> > "Converter between degree Fahrenheit and Celsius
> >
> > Only one key should be specified.
> >
> > If both keys are specified, the results are undefined"
> > (let ((vf (a-realv 'f))
> > (vc (a-realv 'c)))
> > (when f (assert! (=v vf f)))
> > (when c (assert! (=v vc c)))
> > (assert! (=v vf (+v (*v 9/5 vc) 32)))
> > (list vf vc)))
> >
> > I get:
> > SCREAMER-USER> (f<->c :f 32)
> > ([F real 32:32] [C real 0:0])
> >
> > I would like to extract the numerical values.
>
> The values are already bound to f and c. Why do you want to extract
> them out of vf and vc?
>
> Otherwise, there's a value-of function in screamer, but
> (value-of (first (f<->c :f 42))) --> [f real 42:42]
> so I'm not sure that's what you want.
>
>
> > In the documentation I did not see a public method how to extract the
> > range limits. I can use slot-value, but the slot name is not exported.
> > Is there (there must be) a better way. I must be missing something.
>
> Don't use slot-value, but I guess you could use:
> screamer::variable-lower-bound and
> screamer::variable-upper-bound.

I missed those. Maybe those could be exported. I'll submit a request on
the user group.

Thanks

>
> --
> __Pascal Bourguignon__ http://www.informat...
> "The factory of the future will have only two employees, a man and a
> dog. The man will be there to feed the dog. The dog will be there to
> keep the man from touching the equipment." -- Carl Bass CEO Autodesk