From 756d5ee30683a13d93e0009b3c99c25d939a3ef8 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 18 Dec 2014 08:38:37 -0800 Subject: * lib.c (copy): Support copying random state objects vi make_random_state. * txr.1: Updated. --- ChangeLog | 7 +++++++ lib.c | 5 ++++- txr.1 | 28 +++++++++++++++++----------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3c798b09..9dc18282 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-12-18 Kaz Kylheku + + * lib.c (copy): Support copying random state objects + vi make_random_state. + + * txr.1: Updated. + 2014-12-17 Kaz Kylheku * rand.c (rand32): Bugfix: if the seed object is a random diff --git a/lib.c b/lib.c index 8c8fd1b2..a4ce5536 100644 --- a/lib.c +++ b/lib.c @@ -6093,9 +6093,12 @@ val copy(val seq) case COBJ: if (seq->co.cls == hash_s) return copy_hash(seq); + if (seq->co.cls == random_state_s) + return make_random_state(seq); /* fallthrough */ default: - type_mismatch(lit("copy: ~s is not a sequence"), seq, nao); + type_mismatch(lit("copy: cannot copy object of type ~s"), + typeof(seq), nao); } } diff --git a/txr.1 b/txr.1 index 33cfdfee..8151de77 100644 --- a/txr.1 +++ b/txr.1 @@ -17141,41 +17141,47 @@ is zero, otherwise .coNP Function @ copy .synb -.mets (copy << sequence ) +.mets (copy << object ) .syne .desc The .code copy -function duplicates a sequence. If -.meta sequence +function duplicates objects of various supported types: sequences, hashes and random states. If +.meta object is .codn nil , it returns .codn nil . If -.meta sequence +.meta object is a list, it returns .cblk -.meti (copy-list << sequence ). +.meti (copy-list << object ). .cble If -.meta sequence +.meta object is a string, it returns .cblk -.meti (copy-str << sequence ). +.meti (copy-str << object ). .cble If -.meta sequence +.meta object is a vector, it returns .cblk -.meti (copy-vec << sequence ). +.meti (copy-vec << object ). .cble If -.meta sequence +.meta object is a hash, it returns .cblk -.meti (copy-hash << sequence ). +.meti (copy-hash << object ) +.cble +Lastly, if +.meta object +is a random state, it returns +.cblk +.meti (make-random-state << object ). .cble Except in the case when -- cgit v1.2.3