say 1000.primes.grep { .digits.cons(2).all { .head >=.tail } }
Generate such primes from digits (asymptotically faster):
func primes_with_nondecreasing_digits(upto, base =10) { upto = prev_prime(upto+1) var list = [] var digits = @(1..^base -> flip) var end_digits = digits.grep { .is_coprime(base) } list << digits.grep { .is_prime &&!.is_coprime(base) }...for k in (0.. upto.ilog(base)) { digits.combinations_with_repetition(k, {|*a| var v = a.digits2num(base)nextif (v*base + end_digits.tail > upto) end_digits.each {|d| var n = (v*base + d)nextif ((n >= base) && (a[0] > d)) list << n if n.is_prime } }) } list.sort}say primes_with_nondecreasing_digits(1000)