Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $~#~
- $~#~ Input: integer n
- #~ Create n copies of n
- $~ Shape n into an array with dimensions n copies of n
- (t=Table)@@t[#,#+1]&
- (* or *)
- Table@@Table[#,#+1]&
- @(N)ones(N+!(1:N))*N
- @(N)ones(N*ones(1,N))*N
- @(N)repmat(N,N*ones(1,N))
- @(N)ones(num2cell(!(1:N)+N){:})*N
- @(N)repmat(N,num2cell(!(1:N)+N){:})
- n#0=show n
- n#l='[':tail((',':)=<<n#(l-1)<$[1..n])++"]"
- f n=n#n
- n#l= n with the current level l is
- '[': a literal [ followed by
- n#(l-1)<$[1..n] n copies of n # (l-1)
- (',':)=<< each prepended by a , and flattened into a single list
- tail and the first , removed
- ++"]" followed by a literal ]
- n#0=show n the base case is n as a string
- f n=n#n main function, start with level n
- n=scan();array(n,rep(n,n))
- DF¹.D)
- D # Duplicate the input (this leaves the input on the stack after the next command
- F # For 0 .. input
- ¹.D) # Push <input> copies of the result of the last step as an array
- Object c(int n,int i){Object[]a=new Object[n];for(int j=0;j<n;)a[j++]=i<2?n:c(n,i-1);return a;}
- public class N_Dim {
- public static Object create(int n) {
- return create(n, n);
- }
- public static Object create(int n, int i) {
- Object[] array = new Object[n];
- for(int j=0;j<n;j++) {
- array[j] = i<2?n:create(n, i - 1);
- }
- return array;
- }
- public static void main(String[] args) {
- System.out.println(Arrays.deepToString((Object[]) create(3)));
- }
- }
- ri:X{aX*}X*p
- ri:X Read an integer from input, store it in X (leaves it on the stack)
- { }X* Execute this block X times:
- a Wrap the top of stack in an array
- X* Repeat the array X times
- p Print nicely
- ttY"l$l*
- % Implicitly grab the input (N)
- tt % Make two copies of N
- Y" % Perform run-length decoding to create N copies of N
- l$1 % Create a matrix of ones that is this size
- * % Multiply this matrix of ones by N
- % Implicitly display the result
- Wẋ³µ¡
- Implicit input: N
- µ¡ Apply N times to input:
- Wẋ³ “N copies of”
- ⁾Wẋẋv
- ⁾Wẋẋv - Main link: n e.g. 3
- ⁾Wẋ - character pair literal ['W','ẋ'] "Wẋ"
- ẋ - repeat list n times "WẋWẋWẋ"
- v - evaluate as Jelly code with input n eval("WẋWẋWẋ", 3)
- - ...
- WẋWẋ... - toEval: n e.g. 3
- W - wrap [3]
- ẋ - repeat list n times [3,3,3]
- Wẋ - wrap and repeat [[3,3,3],[3,3,3],[3,3,3]]
- ... - n times total [[[3,3,3],[3,3,3],[3,3,3]],[[3,3,3],[3,3,3],[3,3,3]],[[3,3,3],[3,3,3],[3,3,3]]]
- f=(n,m=n)=>m?Array(n).fill(f(n,m-1)):n
- f=(n,m=n)=>m?[...Array(n)].map(_=>f(n,m-1)):n
- ->n{eval'['*n+'n'+']*n'*n}
- for(;$i++<$n=$argv[1];)$F=array_fill(0,$n,$F?:$n);print_r($F);
- #(nth(iterate(fn[a](repeat % a))%)%)
- func[n][array/initial append/dup copy[]n n n]
- @set t=.
- @for /l %%i in (2,1,%1)do @call set t=%%t%%,.
- @set s=%1
- @for /l %%i in (1,1,%1)do @call call set s=[%%%%t:.=%%s%%%%%%]
- @echo %s%
- (defmacro r[n]`(->> ~n ~@(repeat n`(repeat ~n))))
- ->a{(z=a).times{z=[z]*a};z}
- my $x=prompt(0);my @a=$x xx$x;"@a=[@a] xx $x;".EVAL xx$x-1;
- (#(...) {input_no})
- (((3 3 3) (3 3 3) (3 3 3)) ((3 3 3) (3 3 3) (3 3 3)) ((3 3 3) (3 3 3) (3 3 3)))
- def f(x):
- r=[x for _ in range(x)]
- for _ in range(x-1):r=[r for _ in range(x)]
- print(r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement