Home My Page Projects Code Snippets Project Openings SML/NJ
 Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

# SCM Repository

[smlnj] Diff of /smlnj-lib/trunk/Util/bit-array.sml
 [smlnj] / smlnj-lib / trunk / Util / bit-array.sml

# Diff of /smlnj-lib/trunk/Util/bit-array.sml

revision 4108, Mon Sep 21 19:40:44 2015 UTC revision 4109, Mon Sep 21 19:40:56 2015 UTC
# Line 692  Line 692
692                    loop sbit                    loop sbit
693                  end                  end
694
695            (* additional operation from Basis Library proposal 2015-003 *)
696              fun toList (BA{nbits, bits}) = let
697                    fun loop (~1, a) = a
698                      | loop (i, a) = let
699                          val b = ((Word8Array.sub (bits,byteOf i)) & (bit i)) <> 0w0
700                          in
701                            loop (i-1, b :: a)
702                          end
703                    in
704                      loop (nbits-1, [])
705                    end
706
707            end (* local *)            end (* local *)
708          end (* structure Vector *)          end (* structure Vector *)
709
# Line 762  Line 774
774          col 0          col 0
775      end      end
776
777      (* additional operations from Basis Library proposal 2015-003 *)
778        fun fromVector (Vector.BA{nbits, bits}) = let
779              val newBits = Unsafe.Word8Array.create(Word8Array.length bits)
780              in
781                Word8Array.copy{di = 0, dst = newBits, src = bits};
782                BA{nbits = nbits, bits = newBits}
783              end
784
785        val toVector = fromVector
786
787  end (* structure BitArray *)  end (* structure BitArray *)

Legend:
 Removed from v.4108 changed lines Added in v.4109