[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Order of 'label-page-table
From: |
Thomas Morley |
Subject: |
Re: Order of 'label-page-table |
Date: |
Thu, 25 Oct 2012 20:14:00 +0200 |
2012/10/25 David Kastrup <address@hidden>:
> Thomas Morley <address@hidden> writes:
>
>> Well, I managed to order the list with some scheme-code:
>>
>> %%%%%%%%%%%%%%%%%%%%%%%%%%
>>
>> #(define l '((f . 4)(g . 4)(d . 3)(e . 3)(c . 2) (a . 1) (b . 1)))
>>
>> #(define (split-at-equal-cdr alist)
>> "After `split-at-predicate´ from lily-library.scm
>> BTW, why is it not public?
>> "
>> (if (null? alist)
>> (list alist)
>> (let ((i (list-index
>> (lambda (x y) (not (= (cdr x) (cdr y))))
>> alist
>> (cdr alist))))
>> (if i
>> (cons (take alist (1+ i)) (drop alist (1+ i)))
>> (list alist)))))
>>
>> #(define (order-alist l)
>> (define (helper l1 l2)
>> (if (null? l1)
>> l2
>> (helper
>> (cdr (split-at-equal-cdr l1))
>> (append (car (split-at-equal-cdr l1)) l2))))
>> (helper l '()))
>>
>> #(write (order-alist l))
>>
>> %%%%%%%%%%%%%%%%%%%%%%%%%%
>>
>> Returns: ((a . 1) (b . 1) (c . 2) (d . 3) (e . 3) (f . 4) (g . 4))
>> and would be ok.
>
> Eyes glaze over. Wouldn't
> (sort-list l (lambda (a b) (< (cdr a) (cdr b))))
> work here?
Aaargh! Ofcourse it works!
>> Is there any reason for the default-behaviour of 'label-page-table?
>
> No idea.
Pitty.
-Harm