summaryrefslogtreecommitdiff
path: root/modules/language/python/list.scm
diff options
context:
space:
mode:
authorStefan Israelsson Tampe <stefan.itampe@gmail.com>2017-09-23 20:57:50 +0200
committerStefan Israelsson Tampe <stefan.itampe@gmail.com>2017-09-23 20:57:50 +0200
commit5bc1a0f8dd7d6c07380b5e6c56d20a327c0ba587 (patch)
tree96d710188219f79cb5de488137d0681e35ac8cd6 /modules/language/python/list.scm
parent6cb199ed027f0ce56dd2b3f1c94f7edc3a53c026 (diff)
dicts now works almost entirely
Diffstat (limited to 'modules/language/python/list.scm')
-rw-r--r--modules/language/python/list.scm22
1 files changed, 17 insertions, 5 deletions
diff --git a/modules/language/python/list.scm b/modules/language/python/list.scm
index 498934f..094c786 100644
--- a/modules/language/python/list.scm
+++ b/modules/language/python/list.scm
@@ -2,21 +2,32 @@
#:use-module (ice-9 match)
#:use-module (oop pf-objects)
#:use-module (oop goops)
+ #:use-module (language python hash)
#:use-module (language python exceptions)
#:use-module (language python yield)
#:use-module (language python for)
#:use-module (language python try)
#:use-module (language python exceptions)
- #:export (to-list pylist-ref pylist-set! pylist-append!
- pylist-slice pylist-subset! pylist-reverse!
- pylist-pop! pylist-count pylist-extend! len in
- pylist-insert! pylist-remove! pylist-sort!
- pylist-index))
+ #:export (to-list to-pylist
+ pylist-ref pylist-set! pylist-append!
+ pylist-slice pylist-subset! pylist-reverse!
+ pylist-pop! pylist-count pylist-extend! len in
+ pylist-insert! pylist-remove! pylist-sort!
+ pylist-index))
(define-syntax-rule (aif it p x y) (let ((it p)) (if it x y)))
(define-class <py-list> () vec n)
+(define-method (py-hash (o <py-list>))
+ (let ((n (min complexity (slot-ref o 'n)))
+ (v (slot-ref o 'vec)))
+ (let lp ((i 0) (s 0))
+ (if (< i n)
+ (lp (+ i 1)
+ (xy (py-hash (vector-ref v i)) s))
+ s))))
+
(define-method (to-list x)
(if (vector? x)
(vector->list x)
@@ -324,6 +335,7 @@
(vector-set! vec i (vector-ref vec k))
(vector-set! vec k swap))))))
+
(define-method (pylist-reverse! (o <p>) . l)
(apply (ref o 'reverse) l))