to be complete , the form {varriable ← value} with curly brackets used in
simple assignation works too in LET-ARROW*:
scheme@(guile-user)> (let-arrow* ({x ← 1}
{y ← {x + 1}})
x
y)
$2 = 2
but the simpliest form works also:
(let-arrow* (x ← 1
y ← {x + 1})
x
y)
On Saturday, January 2, 2021 at 12:04:35 PM UTC+1 [email protected] wrote:
> hello,
>
> i made a few macros for scheme syntax improvments.
> It uses infix Curly expressions syntax described in SRFI 105
> and could be combined to use with SRFI 47 in multi dimensional arrays.
>
> Curly expressions allows out of the box syntax more mathematicals like:
>
> {c > t} instead of (> c t)
>
> my macros allows more:
>
> assignations of variables, examples:
> (define x '())
> {x ← 2}
> it returns 2,the value of x
> {7 → x} ;; not my own idea suggested by my daughter studying python
> because in math we can write 7 = x in an equation but not in python :-)
>
> {cpt <- 0}
> {cpt <- {cpt + 1}}
>
> but this would be not complete without a way to have vector and array
> access and assignation too:
> (define T (make-vector 5))
> (vector-set! T 3 7)
> {T[3]}
> returns 7, the value of T[3]
>
> assignation of vector:
> {T[3] <- 7}
>
> works too with multidimensional arrays:
> (define a (make-array 999 '(1 2) '(3 4)))
> {a[2 4]}
> returns 999
>
> harder to code, affectaion between arrays and vectors :
> {T[3] <- T[4]}
> ;; assign and returns the value of T[3]
> '{T[3] <- T[4]} will return : (<- ($bracket-apply$ T 3) ($bracket-apply$
> T 4))
>
> {a[1 3] <- a[2 4]}
> {a[2 4] ← 7}
> {1 → a[2 4]}
>
> those works at toplevel of REPL and in statements or block of code or body
> of lambda, now works too with LET end LET* and LETREC in the affectation
> body and in the statements part:
>
> first a simplified LET named LOCAL as in CLOJURE Lisp that use less
> brackets:
> (local [ x 1
> y (+ x 1)
> z (+ 2 y) ]
> z
> y)
>
> returns 2
>
> new special forms :
>
> (let-arrow* (x ← 1
> y ← {x + 1})
> y)
>
> returns 2
>
> (let-arrow* [ x 1
> y (+ x 1)
> z (+ 2 y) ]
> z y)
>
> the same works with LETREC:
>
> (letrec-arrow* [ fact ← (lambda (n)
> (if {n = 1}
> 1
> {n * (fact {n - 1})}))
> ]
> (fact 5))
>
> ;; = 120
>
>
>
> this works with Guile Scheme, the implementation of macros needs only R5RS
> scheme and the SRFI 105, i hope it could works a day in Racket and others
> Scheme implementation .
>
> example in real code:
> https://github.com/damien-mattei/scheme4algo/blob/master/SssRec.scm#L245
>
> the code can be found here:
> for LET-ARROW* and LETREC-ARROW*:
> https://github.com/damien-mattei/library-FunctProg/blob/master/let.scm#L85
>
> Bracket-apply overload and arrows assignations :
>
> https://github.com/damien-mattei/library-FunctProg/blob/master/array.scm#L131
>
> https://github.com/damien-mattei/library-FunctProg/blob/master/array.scm#L101
>
>
> I wrote a little outdated page blog about that:
> http://balistra.canalblog.com/archives/2020/12/01/38692230.html
>
> Racket use different schema for infix notation, one with ($ "string infix
> expression") and another with . (dot) such as (x . + . 1) ,they are not
> usable ,the latter . dot notation is a real nightmare. The best way would
> be to overload the READER of REPL as described in SRFI 105 Curly
> expressions.
>
> Damien
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/f5c24ed0-6981-46d1-b712-481ce728a8e8n%40googlegroups.com.