compound ket fn: hash


hash:
    description:
        hash[b] input-seq
        hash each ket in input-seq, but only keep b bits of the result
        NB: it is a standard c++ hash, and is not cryptographically secure
        Note, sequence structure is preserved

    examples:
        -- compress a range of values into a smaller range:
        hash[2] seq2sp srange(|1>, |10>)
            3|3> + 2|2> + 2|1> + 3|0>

        -- it also preserves sequence structure:
        hash[2] srange(|11>, |15>)
            |2> . |3> . |0> . |2> . |2>

        -- and of course, works for any type of ket label:
        hash[8] ssplit[" "] |Monday Tuesday Wednesday Thursday Friday Saturday Sunday>
            |40> . |154> . |60> . |225> . |18> . |33> . |8>

    see also:

Home