Generate random symbols in Q
A quick way to generate random symbols in Q, with or without replacement is using the following idiom:
x?`y
where x corresponds to the number of symbols in the output list and y is the number of letters for each symbol.
Interestingly, only the letters a though p are used, which gives a possible number of 16^y possible combinations.
Examples:
-10?`1 / Ten random letters from a to p without replacement
10 ? `1 /Ten random letters from a to p with replacement
L: asc -256 ? `1 / `#s `aa`ab…`pp
-17?`1 / `length
Written by Dionysios Barmpoutis
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Random
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#