[MIT-Scheme-users] plotting and fitting data

2015-05-15 Thread David Gray
I’m finding this code useful, so even though 
the intersection of mit-scheme-users and people
who need to use R is small I thought I would
make it available  

https://github.com/dph3dg/mit-scheme-rserve


Cheers
David




___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


[MIT-Scheme-users] let-fluid

2015-08-25 Thread David Gray
I also thought to use the latest version of scmutils20150730 as Frederico.
I managed to compile the latest git version and to compile the latest
version of scmutils but ran into problems with fluid-let using the following 
code:

(fluid-let ((flonum-unparser-cutoff '(relative 5)))
  (number->string (* 4 (atan 1 1

giving:
The object (relative 5), passed as an argument to fluid, is not a fluid.

This is without loading scmutils, as in the past I had problems
with case sensitivity for some constants and thought this may be the problem,
but that is not the case.

Regards
David





___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


[MIT-Scheme-users] imail utf-8 Characters

2016-04-26 Thread David Gray
I get occasional email in Greek and imail makes a real hash of displaying this. 
I expected this
after following the discussion on utf-8 sequences before. My question is is 
there a way to save
this to read in another editor? If I forward the message it can be read OK, but 
not if saved. Does 
the forward just bypass edwin altogether using the message on the server and 
that’s why it works?
I experimented a little and my hope is that the Greek characters are just 
passed through like roughage
and I can reconstruct the correct character later:
#\U039B
#| #\U+039b |#

#\U0A2
#| #\¢ |#

Dave
___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


Re: [MIT-Scheme-users] imail utf-8 Characters

2016-04-27 Thread David Gray
I use 'w' to save and then use emacs to open and also the generic editor on 
OSX. If I forward it to mu4e in emacs the message looks fine.
Here is an example for you to try:

Γεια σου, Ντέιβ,
Η λέξη που ψάχναμε


> On 27 Apr 2016, at 17:47, Taylor R Campbell  wrote:
> 
>  Date: Wed, 27 Apr 2016 09:46:42 +0300
>  From: David Gray 
> 
>  I get occasional email in Greek and imail makes a real hash of
>  displaying this. I expected this after following the discussion on
>  utf-8 sequences before. My question is is there a way to save this
>  to read in another editor? If I forward the message it can be read
>  OK, but not if saved. Does the forward just bypass edwin altogether
>  using the message on the server and that's why it works?
> 
> How are you saving it and how are you reading it?  If you write the
> message body with `w', you should get a plain text file with exactly
> the encoding the message sender specified.  Of course, the text editor
> with which you open it will have to guess the encoding correctly since
> plain text files have no metadata.


___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


[MIT-Scheme-users] Constructing a differential function with ScmUtils

2017-03-09 Thread David Gray
I’m doing some calculations for GVD in various dielectrics, and I thought to 
ask here if anyone knows if there is a less clunky method of constructing the 
differential function with a list of constants:

;;; Refractive Index given Sellmeier coefficients at wavelength in microns
(define (n p1 p2 p3 p4 p5 p6 l)
  (define (d t b l2)
(/ (* t l2) (- l2 b)))
  (let ((l2 (square l)))
(sqrt (+ 1 (d p1 p2 l2) (d p3 p4 l2) (d p5 p6 l2)

(define nofx (lambda (x) (n 'p1 'p2 'p3 'p4 'p5 'p6 x))) 

#| test symbolics
 (nofx 'x)
 ((D nofx) 'x) ; first derivative 
((D (D nofx)) 'x)  ; second derivative - pretty slow from here on but who 
cares
((D (D (D nofx))) 'x)  ; third derivative
|#

;;; BK7 glass coefficients from https://refractiveindex.info
 (define bk7 '(1.03961212 6.00069867e-3 0.231792344 2.00179144e-2 1.01046945 
1.03560653e2))
;;; redefine nods using actual constants 
(define nofx (lambda (x) (n (ref bk7 0)(ref bk7 1)(ref bk7 2)(ref bk7 3)(ref 
bk7 4)(ref bk7 5) x)))
#| numerics
(define l 0.8) ;; Ti:Saph laser wavelength
(nofx l) ;; 1.51078
((D nofx) l) ;; -1.9842e-2
((D (D nofx)) l) ;; 0.04925
((D (D (D nofx))) l) ;; -.28889
All seem pretty consistent with literature up to here.
|#
 

Regards
Dave
___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


Re: [MIT-Scheme-users] Constructing a differential function with ScmUtils

2017-03-09 Thread David Gray
I’m going to deal with a few materials so I thought passing a vector directly 
would be better, but I didn’t manage to differentiate the resulting function 
e.g.: (define (n parameter-vector x)
 …….)
unless I explicitly passed each constant separately. 
___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


Re: [MIT-Scheme-users] Constructing a differential function with ScmUtils

2017-03-09 Thread David Gray

> On 9 Mar 2017, at 11:27, Taylor R Campbell  wrote:
> 
> pe ((D (n (up 'p_1 'p_2 'p_3 ...))) x))
Brilliant, definitely better. I forgot about using tuples. Now it's:
 (define bk7 (up 1.03961212 6.00069867e-3 0.231792344 2.00179144e-2 1.01046945 
1.03560653e2))
((D (n bk7)) 0.8) 

___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


[MIT-Scheme-users] ref error

2017-11-01 Thread David Gray
I’m using ScmUtils 2016 compiled to a band using version 9.2 on OSX, and I’m 
running into a strange error. 
The simplest case I can boil it down to is:
Using *scheme* I can do 
(define (g2d x y v)
  (* (ref v 0) (exp (- (+ (/ (square (- x (ref v 1))) (* 2 (square (ref v 3)) 
)) (/ (square (- y (ref v 2))) (* 2 (square (ref v 4)
And then:
 (g2d 1 2 ‘(1 2 3 4 5))
#| .9500411305585278 |#

However if I save this as a file eg ref-error.scm and then load the file from 
*scheme* I get:
;Unbound variable: ref

 Any ideas?
___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


Re: [MIT-Scheme-users] ref error

2017-11-01 Thread David Gray
This is the scmutils generic ref. When I replace the generic ref with 
vector-ref it works ok, I just thought this error was strange, the only 
difference being loading the file or just using it from the repl.

Sent from my iPad

On 1 Nov 2017, at 20:41, Taylor R Campbell  wrote:

>> Date: Wed, 1 Nov 2017 10:59:18 -0700
>> From: Chris Hanson 
>> 
>> What's ref? Do you mean vector-ref?
> 
> Presumably this is the scmutils generic ref.


___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


Re: [MIT-Scheme-users] ref error

2017-11-02 Thread David Gray
This could have been the case as I was messing around in the repl. However when 
I tried to find the simplest case to replicate
the error I restarted scheme, did a load, then got the error. Then I restarted 
again, pasted the code from the file to *scheme*
where everything was OK. Another thing that was strange was that I could do 
(ref ‘(1 2 3 4 5) 2) in *scheme* after the error, as it
was only the loaded function that gave the error.   

> On 2 Nov 2017, at 00:11, Matt Birkholz  wrote:
> 
> On Wed, 2017-11-01 at 23:59 +0200, David Gray wrote:
>> This is the scmutils generic ref. When I replace the generic ref with
>> vector-ref it works ok, I just thought this error was strange, the
>> only difference being loading the file or just using it from the
>> repl.
> 
> There is this "gotcha" with the *scheme* buffer:
> 
>After examining an error, whether or not you choose to enter the
>debugger, you should type "C-c C-c" to get back to the top level.
>This is important because if you don't the evaluations you
>subsequently perform may refer to the error state rather than to the
>state you intended.  [scmutils/manual/beginner.txt]
> 
> It sounds like the wrong environment was used somewhere.


___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


[MIT-Scheme-users] scmutils

2018-11-05 Thread David Gray
Has anyone tried to compile scmutils using 10.2?
I got as far as kernel/utils.scm failing on #F 
which I changed to #f and display/exdisplay.scm 
where there's \SPACE which I changed to \space assuming
problems with case. Then I got a premature EOF at which
point I gave up.  Maybe this is stupid to even try with
such big changes to the underlying scheme.


Dave

___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


[MIT-Scheme-users] Large integers

2018-11-07 Thread David Gray
as per instructions, bug finding:
The old system 9.2 let you do stupid things like
(/ (expt 2 100) (expt 2 100))
and you would get a warning about running out of memory.
In 10.2.1 in just hangs (the REPL:listen in edwin doesn't 
change to REPl:eval) and according to my process monitor on OSX
the cpu is churning away at 100%.



___
MIT-Scheme-users mailing list
MIT-Scheme-users@gnu.org
https://lists.gnu.org/mailman/listinfo/mit-scheme-users


Fonts/Edwin/osx

2021-01-11 Thread David Gray
In the past I could never get a nice font with Edwin and OSX, there were always 
scaling issues.
Recently I found the Terminus font which you can install as a TTF but also has 
the bitmaps included.
So if you use your display dpi and you use one of the bitmap px sizes of 12 to 
32 in steps of 2
And set pt = (px/dpi)*72. The rounding seems to be up so for instance 
(22/92)*72 = 17.2. 17
Still looks awful but 18 as set below seems great.
In .edwin:
((ref-command set-font) "-misc-terminus  ttf 
-medium-r-normal--18-0-0-0-m-0-iso8859-1”)





Http-get format

2021-04-17 Thread David Gray
I looked into the source code for the http-get format but I’m not able to 
format my request correctly.

For a plain http without authorisation I can do:
(http-response-body (http-get "http://192.168.1.90/jpg/1/image.jpg"; '((Host . \
"192.168.1.90"
Then I can save the image.
However if I have Basic Authorization setup I don’t seem to be able to get the 
correct form of the header. The closest
Form I’ve used is:
(http-get (->uri "http://192.168.1.90/jpg/1/image.jpg";) (make-http-header 'Auth\
orization "Authorization: Basic xx”))
With the error: The object #[http-header 41 authorization] is not the correct 
type.

Querying the record from the header hasn’t given me any clues.







Apple M1 emulation errors

2021-10-13 Thread David Gray
I’m trying to get scmutils running under Rosetta emulation on a M1 apple.
Using arch -x86_64 can get a semi working system for version 11.x.
Edwin fails but scheme.el works OK with emacs. When I try the same
thing with version 10.1.11in order to get scmutils  I get some strange 
behaviour:
(+ 2 2) is OK but if I try anything to do with i/o eg
 (cf “fib.scm”) -> ;Generating SCode for file: "fib.scm" => "fib.bin"...
;The port #[textual-input-port 12 for file: "/Users/dave/space/fib.scm"] 
signalled an error #[condition 13 "system-call-error"]:
The primitive channel-read, while executing the read system call, received the 
error: Bad address. 

Also if I do the same with a relative directory eg:
(cf “~/space/fib”) ;Generating SCode for file: "/home/cph/space/fib.scm" => 
"/home/cph/space/fib.bin"...
;Unable to open file "/home/cph/space/fib.scm" because: No such file or 
directory.

It seems to have a hardwired directory from somebody who’s initials are cph.


  


If statements

2022-07-07 Thread David Gray

Something a little more prosaic after the last set of messages on 
mit-scheme-devel.
Just to get a feel for the speed and stability of a new system I run a long 
Fibonacci recursive functioning and I must have mixed up an old version which 
was much faster, (fib 42) -> 3s instead of 25s, and the only difference seems 
to be the following if statement.

(if (<= n 2)
1
(fib…….

(if (or (= n 1)
  (= n 2)
 1
(fib………

Is the underlying code so different?


 

Shell

2022-10-17 Thread David Gray
When I run shell from Edwin with macO(zsh) I cannot set the prompt correctly. 
I have the following code that gets round some issues with bracketed paste. 


if [[ $TERM == "emacs" || $TERM == "dumb" ]]
then
  unsetopt zle
  unsetopt prompt_cr
  unsetopt prompt_subst
  if whence -w precmd >/dev/null; then
  unfunction precmd
  fi
  if whence -w preexec >/dev/null; then
  unfunction preexec
  fi
  PS1='$ '
  return
fi

zle_highlight=('paste:none’)


With a plain dumb terminal this is OK but in Edwin I always get:
^[];file://^G 
And then the PS1 prompt.





(cf "somefile.scm") error

2023-10-13 Thread David Gray
How to track down the following error?

In the latest scheme (12.1) compiled exactly as the instructions for a unix 
binary and with a plain Xcode command line system I get a fully working system 
under the Monterey version of macOS. However from Ventura on I am not able to 
compile a simple scheme file. If the file has already been compiled under 
Monterey I can load the file and experience 50x faster function calls but I 
cannot re-compile it

The error is:
(cf "fib-sonoma.scm")
;Generating SCode for file: "fib-sonoma.scm" => "fib-sonoma.bin"... done
;Compiling file: "fib-sonoma.bin" => "fib-sonoma.com"...
;Warning: Procedure called with wrong number of arguments #[primitive-procedure 
15 %record-length] 2
;Warning: Procedure called with wrong number of arguments #[primitive-procedure 
15 %record-length] 2
;Primitive called with incorrect number of arguments. #[primitive-procedure 15 
%record-length] 2
;To continue, call RESTART with an option number:
; (RESTART 2) => Return to read-eval-print level 2.

What is the best way to try to track this down. I tried various things:

Compile mit-scheme x86_64 under Monterey and transfer to Sonoma
Compile mit-scheme x86_64 under Sonoma
Compile portable SVM under Sonoma

I’ve run out of energy to try gcc


Re: (cf "somefile.scm") error

2023-10-13 Thread David Gray
I forgot to add:
if you don’t add "(declare (usual-integrations))”
it will compile but if you load the file you get:
(load "fib-sonoma")
;Loading "fib-sonoma.com"...
;The object fib, passed as an argument to return-address->stack-frame-type, is 
not in the correct range.


> On 13 Oct 2023, at 11:30 AM, David Gray  wrote:
> 
> How to track down the following error?
> 
> In the latest scheme (12.1) compiled exactly as the instructions for a unix 
> binary and with a plain Xcode command line system I get a fully working 
> system under the Monterey version of macOS. However from Ventura on I am not 
> able to compile a simple scheme file. If the file has already been compiled 
> under Monterey I can load the file and experience 50x faster function calls 
> but I cannot re-compile it
> 
> The error is:
> (cf "fib-sonoma.scm")
> ;Generating SCode for file: "fib-sonoma.scm" => "fib-sonoma.bin"... done
> ;Compiling file: "fib-sonoma.bin" => "fib-sonoma.com"...
> ;Warning: Procedure called with wrong number of arguments 
> #[primitive-procedure 15 %record-length] 2
> ;Warning: Procedure called with wrong number of arguments 
> #[primitive-procedure 15 %record-length] 2
> ;Primitive called with incorrect number of arguments. #[primitive-procedure 
> 15 %record-length] 2
> ;To continue, call RESTART with an option number:
> ; (RESTART 2) => Return to read-eval-print level 2.
> 
> What is the best way to try to track this down. I tried various things:
> 
> Compile mit-scheme x86_64 under Monterey and transfer to Sonoma
> Compile mit-scheme x86_64 under Sonoma
> Compile portable SVM under Sonoma
> 
> I’ve run out of energy to try gcc
> 
> 




Re: (cf "somefile.scm") error

2023-10-18 Thread David Gray
The debugger output is as follows:
Primitive called with incorrect number of arguments. #[primitive-procedure 13 
%record-length] 2

>S0  (if (not (primitive-arity-correct? primitive frame-size)) (error "Prim ...

 SUBPROBLEM LEVEL: 0

COMPILED expression (from stack):
 Subproblem being executed is highlighted.

(begin
 (if (not (primitive-arity-correct? primitive frame-size))
 (error "Primitive called with incorrect number of arguments."
primitive
frame-size))
 ((or (special-primitive-handler primitive)
  rtl:make-invocation:primitive)
  (|1+| frame-size)
  continuation
  primitive))

>S1  (let ((primitive (vector-ref (rvalue-known-value operator) 2))) (if (n ...

(scfg*scfg->scfg!
 (prefix frame-size 0)
 (let ((primitive (vector-ref ... 2)))
   (if (not (primitive-arity-correct? primitive frame-size))
   (error "Primitive called with incorrect number of arguments."
  primitive
  frame-size))
   ((or (special-primitive-handler primitive)
rtl:make-invocation:primitive)
(|1+| frame-size)
continuation
primitive)))

>S2 (generate/node/no-memoize node)

 (rtl-precompress! (generate/node/no-memoize node))

>S3 (generate/node/ (edge-next-node) (vector-ref node 6)))

(scfg*scfg->scfg! (generator node)
  (generate/node (edge-next-node (vector-ref node 6

S4 to S9 are pairs the same as S2 and S3



> On 17 Oct 2023, at 10:49 PM, Chris Hanson  wrote:
> 
> Sorry for the long delay in responding.
> 
> I'd be interested in seeing what the debugger shows for that error. Can you 
> run it and show the first few frames to give me an idea where the problem is?
> 
> On 10/13/23 04:30, David Gray wrote:
>> How to track down the following error?
>> In the latest scheme (12.1) compiled exactly as the instructions for a unix 
>> binary and with a plain Xcode command line system I get a fully working 
>> system under the Monterey version of macOS. However from Ventura on I am not 
>> able to compile a simple scheme file. If the file has already been compiled 
>> under Monterey I can load the file and experience 50x faster function calls 
>> but I cannot re-compile it
>> The error is:
>> (cf "fib-sonoma.scm")
>> ;Generating SCode for file: "fib-sonoma.scm" => "fib-sonoma.bin"... done
>> ;Compiling file: "fib-sonoma.bin" => "fib-sonoma.com"...
>> ;Warning: Procedure called with wrong number of arguments 
>> #[primitive-procedure 15 %record-length] 2
>> ;Warning: Procedure called with wrong number of arguments 
>> #[primitive-procedure 15 %record-length] 2
>> ;Primitive called with incorrect number of arguments. #[primitive-procedure 
>> 15 %record-length] 2
>> ;To continue, call RESTART with an option number:
>> ; (RESTART 2) => Return to read-eval-print level 2.
>> What is the best way to try to track this down. I tried various things:
>> Compile mit-scheme x86_64 under Monterey and transfer to Sonoma
>> Compile mit-scheme x86_64 under Sonoma
>> Compile portable SVM under Sonoma
>> I’ve run out of energy to try gcc
>