guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

matlab extension for entering matrices in Guile


From: Matt Wette
Subject: matlab extension for entering matrices in Guile
Date: Fri, 17 Aug 2018 09:03:01 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Hi all,

So I'm working on a "not exactly" matlab (or octave) extension language for 
Guile.
One useful feature of matlab is that it has simple syntax for expressing 
matrices.
I am trying to use the following constraints for "[" ... "]".  What do you 
think?
1) a sequence of comma-separated scalar integers => Scheme vector of integers
   (This might be used for matrix indices)
2) otherwise, everything between "[" and "]" => typed-array of f64

scheme@(guile-user)> ,L nx-matlab
Happy hacking with nx-matlab!  To switch back, type `,L scheme'.

nx-matlab@(guile-user)> a = [1 , 2, 3];

nx-matlab@(guile-user)> ,L scheme
Happy hacking with Scheme!  To switch back, type `,L nx-matlab'.

scheme@(guile-user)> (vector-ref a 0)
$3 = 1


scheme@(guile-user)> ,L nx-matlab
Happy hacking with nx-matlab!  To switch back, type `,L scheme'.

nx-matlab@(guile-user)> b = [ 1.0, 2.0, 3.0; 4.0, 5.0, 6.0];

nx-matlab@(guile-user)> ,L scheme
Happy hacking with Scheme!  To switch back, type `,L nx-matlab'.

scheme@(guile-user)> (array-ref b 1 2)
$1 = 6.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]