Re: scheme set list function

2019-04-09 Thread Gianmaria Lari
On Tue, 9 Apr 2019 at 10:29, David Kastrup wrote: > Gianmaria Lari writes: > > > Ciao Harm, Andrew, Aaron and David, > > > > this is what I have been able to do adapting Harm code: > > > > \version "2.21.0" > > foo = > > #(let ((x '(1))) > > (define-scheme-function (arg)(symbol?) > >

Re: scheme set list function

2019-04-09 Thread David Kastrup
Gianmaria Lari writes: > Ciao Harm, Andrew, Aaron and David, > > this is what I have been able to do adapting Harm code: > > \version "2.21.0" > foo = > #(let ((x '(1))) > (define-scheme-function (arg)(symbol?) > (case arg > ((incNumber) (set! x (append (drop-right x 1) (list (1+

Re: scheme set list function

2019-04-09 Thread Gianmaria Lari
Ciao Harm, Andrew, Aaron and David, this is what I have been able to do adapting Harm code: \version "2.21.0" foo = #(let ((x '(1))) (define-scheme-function (arg)(symbol?) (case arg ((incNumber) (set! x (append (drop-right x 1) (list (1+ (last x)) ((unindent) (drop-right! x

Re: scheme set list function

2019-04-08 Thread Thomas Morley
Hi Carl, Am Mo., 8. Apr. 2019 um 15:05 Uhr schrieb Carl Sorensen : > But you haven't implemented 'start in this code, have you?It's a default > no-op. You could start your indentation by using any symbol that is not > 'reset, 'increase, or 'indent, iIUC. Exactly. I should have dropped a

Re: scheme set list function

2019-04-08 Thread Thomas Morley
Am Mo., 8. Apr. 2019 um 13:17 Uhr schrieb Aaron Hill : > > On 2019-04-08 2:48 am, Thomas Morley wrote: > > foo = > > #(let ((x (cons 1 0))) > > (define-scheme-function (arg)(symbol?) > > (case arg > > ((indent) (set! x (cons (car x) (1+ (cdr x) > > ((increase) (set! x (cons

Re: scheme set list function

2019-04-08 Thread Gianmaria Lari
On Mon, 8 Apr 2019 at 11:49, Thomas Morley wrote: > Am Mo., 8. Apr. 2019 um 10:07 Uhr schrieb Gianmaria Lari > : > > > > I try to explain what I'm trying to do. > > > > I want some functions helping me to numbering exercise like this: > > > > 1 > > 2 > > 3 > > 3.1 > > 3.2 > > 3.3 > > 4 > > 4.1 >

Re: scheme set list function

2019-04-08 Thread David Kastrup
Aaron Hill writes: > On 2019-04-08 4:35 am, David Kastrup wrote: >> >> There is no global variable x. There is a binding, but the scope of >> the binding ends with the let. This binding is anonymous afterwards >> and has no name. You can call functions manipulating the global >> variable x

Re: scheme set list function

2019-04-08 Thread David Kastrup
Aaron Hill writes: > On 2019-04-08 4:08 am, David Kastrup wrote: >> Aaron Hill writes: >>> As such, procedures can have side effects where the objects that are >>> passed to such procedures may be modified. Consider the 1+last! >>> procedure I showed that is not a macro itself, but it still

Re: scheme set list function

2019-04-08 Thread Carl Sorensen
On 4/8/19, 3:48 AM, "Thomas Morley" wrote: Am Mo., 8. Apr. 2019 um 10:07 Uhr schrieb Gianmaria Lari : > > I try to explain what I'm trying to do. > > I want some functions helping me to numbering exercise like this: > > 1 > 2 > 3 > 3.1 > 3.2

Re: scheme set list function

2019-04-08 Thread Aaron Hill
On 2019-04-08 5:31 am, Andrew Bernard wrote: Hi All, Here's a very well written post on pointers in Scheme (it doesn't have them, full stop). Wonderful language that it is, you can create something similar for yourself. We do not have access to pointers in the Scheme language, as it is

Re: scheme set list function

2019-04-08 Thread Aaron Hill
On 2019-04-08 4:08 am, David Kastrup wrote: Aaron Hill writes: As such, procedures can have side effects where the objects that are passed to such procedures may be modified. Consider the 1+last! procedure I showed that is not a macro itself, but it still has the side effect of altering the

Re: scheme set list function

2019-04-08 Thread Andrew Bernard
Hi All, Here's a very well written post on pointers in Scheme (it doesn't have them, full stop). Wonderful language that it is, you can create something similar for yourself. https://www.quora.com/How-are-pointers-in-Scheme-different-from-C Observe that this post also clearly states the Scheme

Re: scheme set list function

2019-04-08 Thread Andrew Bernard
Hi Aaron, I beg to differ. Here plain and clear from the start of the R5RS Scheme specification is the following: Arguments to Scheme procedures are always passed by value, which means that the actual argument expressions are evaluated before the procedure gains control, whether the procedure

Re: scheme set list function

2019-04-08 Thread Aaron Hill
On 2019-04-08 4:35 am, David Kastrup wrote: Aaron Hill writes: On 2019-04-08 2:48 am, Thomas Morley wrote: foo = #(let ((x (cons 1 0))) (define-scheme-function (arg)(symbol?) (case arg ((indent) (set! x (cons (car x) (1+ (cdr x) ((increase) (set! x (cons (1+ (car x))

Re: scheme set list function

2019-04-08 Thread David Kastrup
Aaron Hill writes: > On 2019-04-08 2:48 am, Thomas Morley wrote: >> foo = >> #(let ((x (cons 1 0))) >> (define-scheme-function (arg)(symbol?) >> (case arg >> ((indent) (set! x (cons (car x) (1+ (cdr x) >> ((increase) (set! x (cons (1+ (car x)) 0))) >> ((reset) (set! x

Re: scheme set list function

2019-04-08 Thread Aaron Hill
On 2019-04-08 2:48 am, Thomas Morley wrote: foo = #(let ((x (cons 1 0))) (define-scheme-function (arg)(symbol?) (case arg ((indent) (set! x (cons (car x) (1+ (cdr x) ((increase) (set! x (cons (1+ (car x)) 0))) ((reset) (set! x (cons 1 0 (if (zero? (cdr x))

Re: scheme set list function

2019-04-08 Thread David Kastrup
Aaron Hill writes: > On 2019-04-07 6:01 pm, Andrew Bernard wrote: >> I am somewhat concerned that there is a misunderstanding you have about >> Scheme. Scheme procedures are call-by-value. This means the >> arguments are >> evaluated and the value then passed to the procedure. The value of the

Re: scheme set list function

2019-04-08 Thread Thomas Morley
Am Mo., 8. Apr. 2019 um 10:07 Uhr schrieb Gianmaria Lari : > > I try to explain what I'm trying to do. > > I want some functions helping me to numbering exercise like this: > > 1 > 2 > 3 > 3.1 > 3.2 > 3.3 > 4 > 4.1 > 4.2 > > etc. > I thought that an alternative approach that looks nice to try but

Re: scheme set list function

2019-04-08 Thread Gianmaria Lari
I try to explain what I'm trying to do. I want some functions helping me to numbering exercise like this: 1 2 3 3.1 3.2 3.3 4 4.1 4.2 etc. For that I thought to use the following three functions: #(define (incNumber l) (append (drop-right l 1) (list (1+ (last l) #(define (unindent l)

Re: scheme set list function

2019-04-07 Thread Urs Liska
Am 8. April 2019 03:01:26 MESZ schrieb Andrew Bernard : >Hi Gianmaria, > >Can you explain the purpose of nulling out the list? > >I am somewhat concerned that there is a misunderstanding you have about >Scheme. Scheme procedures are call-by-value. This means the arguments >are >evaluated and

Re: scheme set list function

2019-04-07 Thread Aaron Hill
On 2019-04-07 6:01 pm, Andrew Bernard wrote: I am somewhat concerned that there is a misunderstanding you have about Scheme. Scheme procedures are call-by-value. This means the arguments are evaluated and the value then passed to the procedure. The value of the parameter in the calling

Re: scheme set list function

2019-04-07 Thread Andrew Bernard
Hi Gianmaria, Can you explain the purpose of nulling out the list? I am somewhat concerned that there is a misunderstanding you have about Scheme. Scheme procedures are call-by-value. This means the arguments are evaluated and the value then passed to the procedure. The value of the parameter in

Re: scheme set list function

2019-04-06 Thread Gianmaria Lari
Thank you Harm and Aaron! I tested your solutions;they both work and I think there are pretty clear!! But I think, next days I will try to explain what I'm doing. Thanks a lot!!! g. On Sat, 6 Apr 2019 at 19:09, Aaron Hill wrote: > On 2019-04-06 9:50 am, Thomas Morley wrote: > > Though, I'd

Re: scheme set list function

2019-04-06 Thread Aaron Hill
On 2019-04-06 9:50 am, Thomas Morley wrote: Though, I'd think you should rethink whatever you plan, I'm very skeptic about always resetting a toplevel defined list. It's too destructive. Also, it is convention to use an exclamation point as a suffix when naming procedures that may modify the

Re: scheme set list function

2019-04-06 Thread Thomas Morley
Am Sa., 6. Apr. 2019 um 17:21 Uhr schrieb Gianmaria Lari : > > On Sat, 6 Apr 2019 at 16:30, Thomas Morley wrote: >> One possibility is to use a macro: >> >> #(define-macro (reset-list l) `(set! ,l '())) > > > Thank you, it works. > > I tried to make the same with the second of these functions: >

Re: scheme set list function

2019-04-06 Thread Gianmaria Lari
On Sat, 6 Apr 2019 at 16:30, Thomas Morley wrote: > Am Sa., 6. Apr. 2019 um 16:11 Uhr schrieb Gianmaria Lari > : > > > > I wrote this function > > > > #(define (resetList l) (set! l '())) > > > > > > that I would like to set a list to an empty list. This is an example of > use: > > > > \version

Re: scheme set list function

2019-04-06 Thread Thomas Morley
Am Sa., 6. Apr. 2019 um 16:11 Uhr schrieb Gianmaria Lari : > > I wrote this function > > #(define (resetList l) (set! l '())) > > > that I would like to set a list to an empty list. This is an example of use: > > \version "2.21.0" > #(define mylist '(1 2 3)) > \markup #(object->string mylist)

scheme set list function

2019-04-06 Thread Gianmaria Lari
I wrote this function #(define (resetList l) (set! l '())) that I would like to set a list to an empty list. This is an example of use: \version "2.21.0" #(define mylist '(1 2 3)) \markup #(object->string mylist) %this prints (1 2 3) #(define (resetList l) (set! l '())) #(resetList mylist)