matrix of bits

alright, heres my newest task that should be easy that has given me nothing but problems....

I have a function, sFunction, that takes in something between 0 and 15 (*only* integers) and spits out a single value.

I would like to create a matrix of the output's bits. Since my numbers are 4 bit, that means it should be 4 wide and 16 high. To get the bits I'm planning on BitAnd-ing them with a power of 2 to isolate it.

I keep getting "too many levels of recursion" errors on all my attempts.

Anyone happen to know of a easy way to go about this, so i can just specify sFunction and be done with this?

Thanks

alec's picture

For example

For example,

Matrix(map(Bits:-Split,sBox));
                          [0    0    1    1]
                          [                ]
                          [1    0    1    0]
                          [                ]
                          [0    1    1    0]
                          [                ]
                          [1    1    0    1]
                          [                ]
                          [1    0    0    1]
                          [                ]
                          [0    0    0    0]
                          [                ]
                          [0    1    0    1]
                          [                ]
                          [1    0    1    1]
                          [                ]
                          [1    1    0    0]
                          [                ]
                          [0    1    1    1]
                          [                ]
                          [1    1    1    1]
                          [                ]
                          [0    0    0    1]
                          [                ]
                          [1    1    1    0]
                          [                ]
                          [1    0    0    0]
                          [                ]
                          [0    1    0    0]

The same result can be produced with

Matrix(map(convert,sBox,base,2));

Alec

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}