Re: Validating a Scheme list

2014-05-15 Thread David Kastrup
Orm Finnendahl writes: > Hi David, > > I wasn't aware that SRFI-1 is included in lilypond. Is there any > documentation about which libs/packages are included in lilypond? I don't think that it's documented (and it's not all that much more). But of course you can call use-modules yourself anywa

Re: Validating a Scheme list

2014-05-15 Thread Orm Finnendahl
Hi David, I wasn't aware that SRFI-1 is included in lilypond. Is there any documentation about which libs/packages are included in lilypond? -- Orm Am Donnerstag, den 15. Mai 2014 um 10:26:07 Uhr (+0200) schrieb David Kastrup: > (if (every (lambda (sig) (eqv 2 (length+ sig))) lst) > (displa

Re: [SPAM] Re: Validating a Scheme list

2014-05-15 Thread Urs Liska
Am 15.05.2014 10:26, schrieb David Kastrup: Urs Liska writes: Hi all, I am working on a Scheme function and would like to check if I have found the best solution for a specific subpart. Somehow it looks more complicated than necessary. The function needs to test if each element of a given

Re: Validating a Scheme list

2014-05-15 Thread David Kastrup
Urs Liska writes: > Hi all, > > I am working on a Scheme function and would like to check if I have found the > best solution for a specific subpart. Somehow it looks more complicated than > necessary. > > The function needs to test if each element of a given list is a (sub)list > with exactly

Re: Validating a Scheme list

2014-05-15 Thread Urs Liska
Am 15.05.2014 10:41, schrieb Orm Finnendahl: Hi Urs, it doesn't make too much sense to first collect the whole list and then check for membership of #f. It'd be more reasonable to stop iteration once any of the preconditions isn't met. Ah yes, I didn't mention that this is exactly what I tho

Re: Validating a Scheme list

2014-05-15 Thread Malte Meyn
Hi, I almost don’t know any Scheme but I think this could be done with a map, a fold, and some function composition. In Haskell, you would do this: validate = foldr (&&) True . map ((== 2) . length) validateShort = and . map ((== 2) . length) The function and is a shortcut de

Re: Validating a Scheme list

2014-05-15 Thread Orm Finnendahl
Hi Urs, it doesn't make too much sense to first collect the whole list and then check for membership of #f. It'd be more reasonable to stop iteration once any of the preconditions isn't met. You could achieve this by using a recursive function like below (you could make it more terse by using if

Validating a Scheme list

2014-05-15 Thread Urs Liska
Hi all, I am working on a Scheme function and would like to check if I have found the best solution for a specific subpart. Somehow it looks more complicated than necessary. The function needs to test if each element of a given list is a (sub)list with exactly two elements. So '((1 2)(3 4))