GIMP Script-fu

Check-in [9e56fa2e77]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:merged from branch.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9e56fa2e77b00cb3da1c010ba930aa9f7ca0c1ed
User & Date: saul 2015-04-05 05:05:12
Context
2015-05-22
21:34
Float layer added to useful functions. check-in: 260a9faba6 user: saul tags: trunk
2015-04-05
05:05
merged from branch. check-in: 9e56fa2e77 user: saul tags: trunk
05:03
Substituted an optimized merge sort, replacing sort. check-in: 3ff6a97002 user: saul tags: schemey-fu
2015-03-28
02:59
Schemey-fu into trunk. check-in: 56700dd57f user: saul tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to schemey-fu.scm.

1253
1254
1255
1256
1257
1258
1259
1260

1261
1262
1263

1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284

1285

1286
1287
1288



1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299


1300
1301
1302
1303
1304
1305
1306
            (let ((result (reverse (cons end result))))
              (if (null? args)
                (map inexact->exact result)
                result))
            (loop (pred count)
                  (cons (op adjustment (car result)) result) ))))))

    ; 'sort optimal for short lists (< 100 items)

    (define (sort < lis)
        (define (insert x sorted)
            (if (null? sorted)

                (list x)
                (if (< x (car sorted))
                    (cons x sorted)
                    (cons (car sorted) (insert x (cdr sorted))))))
        (if (null? lis)
            '()
            (insert (car lis) (sort < (cdr lis)))))                 
    
    (define (split lis)
      (let loop ((lis lis)
                 (right lis)
                 (left '()))
        (if (or (null? lis) (null? (cdr lis)))
          (cons (reverse left) right)
          (loop (cddr lis) 
                (cdr right) 
                (cons (car right) left)))))
      
    (define (merge < left right)
      (cond
        ((null? left) right)

        ((null? right) left)

        ((< (car left) (car right))
         (cons (car left) (Fu::merge < (cdr left) right)))
        (else (cons (car right) (Fu::merge < left (cdr right))))))



        
    ; msort (merge sort) optimal for longer lists (> 20 items)
    (define (msort < lis)
      (cond
        ((null? lis) lis)
        ((null? (cdr lis)) lis)
        (else (let ((halves (Fu::split lis)))
                (Fu::merge <
                  (msort < (car halves))
                  (msort < (cdr halves)))))))



    ))

;; Schemey-fu also provides some useful macros
(define-macro (with-context . body)
  `(begin
     (gimp-context-push)
     ,@body







|
>

|
<
>
|
<
|
|
|
|
<
<
|
<
<
<
<
<
<
<
<
<
<
|
|
>
|
>
|
<
<
>
>
>
|
<
<
<
|
<
<
<
<
<
<
>
>







1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263

1264
1265

1266
1267
1268
1269


1270










1271
1272
1273
1274
1275
1276


1277
1278
1279
1280



1281






1282
1283
1284
1285
1286
1287
1288
1289
1290
            (let ((result (reverse (cons end result))))
              (if (null? args)
                (map inexact->exact result)
                result))
            (loop (pred count)
                  (cons (op adjustment (car result)) result) ))))))

    ; This sort is an optimized merge sort.
    ;
    (define (sort < lis)
      (define (dosort < lis n)

        (if (= n 1)
          (list (car lis))

          (let ((i (quotient n 2)))
            (domerge <
                     (dosort < lis i)
                     (dosort < (list-tail lis i) (- n i))))))


      (define (domerge < lis1 lis2)










        (cond
          ((null? lis1) 
            lis2)
          ((null? lis2) 
            lis1)
          ((< (car lis2) (car lis1))


            (cons (car lis2) (domerge < lis1 (cdr lis2) )))
          (else
            (cons (car lis1) (domerge < (cdr lis1) lis2)))))
      



      (if (null? lis) 






        lis 
        (dosort < lis (length lis))))
    ))

;; Schemey-fu also provides some useful macros
(define-macro (with-context . body)
  `(begin
     (gimp-context-push)
     ,@body