mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-14 08:50:48 -07:00
random-state: make-random-state accepts arrays
Type of the array is checked. The code has been moved from the `#$' reader-macro simplifying its implementation.
This commit is contained in:
parent
c196d0f0e7
commit
ab2e5a3593
2 changed files with 15 additions and 20 deletions
|
|
@ -300,6 +300,20 @@ ecl_make_random_state(cl_object rs)
|
|||
case t_fixnum:
|
||||
z->random.value = init_genrand(ecl_fixnum(rs));
|
||||
break;
|
||||
case t_vector: /* intentionaly undocumented (only for internal use) */
|
||||
#if ECL_FIXNUM_BITS > 32
|
||||
if (rs->vector.dim == 313 && rs->vector.elttype == ecl_aet_b64) {
|
||||
z = ecl_alloc_object(t_random);
|
||||
z->random.value = cl_copy_seq(rs);
|
||||
break;
|
||||
}
|
||||
#else /* 32 bit version */
|
||||
if (rs->vector.dim == 625 && rs->vector.elttype == ecl_aet_b32) {
|
||||
z = ecl_alloc_object(t_random);
|
||||
z->random.value = cl_copy_seq(rs);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
FEwrong_type_only_arg(@[make-random-state], rs,
|
||||
ecl_read_from_cstring(type));
|
||||
|
|
|
|||
21
src/c/read.d
21
src/c/read.d
|
|
@ -1383,26 +1383,7 @@ sharp_dollar_reader(cl_object in, cl_object c, cl_object d)
|
|||
if (d != ECL_NIL && !read_suppress)
|
||||
extra_argument('$', in, d);
|
||||
c = ecl_read_object(in);
|
||||
|
||||
switch (ecl_t_of(c)) {
|
||||
case t_vector:
|
||||
#if ECL_FIXNUM_BITS > 32
|
||||
if (c->vector.dim == 313 && c->vector.elttype == ecl_aet_b64) {
|
||||
rs = ecl_alloc_object(t_random);
|
||||
rs->random.value = cl_copy_seq(c);
|
||||
break;
|
||||
}
|
||||
#else /* 32 bit version */
|
||||
if (c->vector.dim == 625 && c->vector.elttype == ecl_aet_b32) {
|
||||
rs = ecl_alloc_object(t_random);
|
||||
rs->random.value = cl_copy_seq(c);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
rs = ecl_make_random_state(c);
|
||||
break;
|
||||
}
|
||||
rs = ecl_make_random_state(c);
|
||||
|
||||
@(return rs);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue