}
} ;
-HELP: bits
+HELP: bits
{ $values { "m" integer } { "n" integer } { "m'" integer } }
{ $description "Keep only n bits from the integer m." }
{ $example "USING: math.bitwise prettyprint ;" "HEX: 123abcdef 16 bits .h" "cdef" } ;
{ "?" "a boolean" }
}
{ $description "Returns " { $link t } " if the nth bit is set to zero." }
-{ $examples
+{ $examples
{ $example "USING: math.bitwise prettyprint ;"
"HEX: ff 8 bit-clear? ."
"t"
}
- { $example "" "USING: math.bitwise prettyprint ;"
+ { $example "USING: math.bitwise prettyprint ;"
"HEX: ff 7 bit-clear? ."
"f"
}
{ "n" integer }
}
{ $description "Returns the number of set bits as an object. This word only works on non-negative integers or objects that can be represented as a byte-array." }
-{ $examples
+{ $examples
{ $example "USING: math.bitwise prettyprint ;"
"HEX: f0 bit-count ."
"4"
{ $values
{ "m" integer } { "s" integer }
{ "n" integer }
-}
+}
{ $description "Rolls the number " { $snippet "m" } " by " { $snippet "s" } " bits to the left, wrapping around after 32 bits." }
-{ $examples
+{ $examples
{ $example "USING: math.bitwise prettyprint ;"
"HEX: 1 10 bitroll-32 .h"
"400"
{ "n" integer }
}
{ $description "Rolls the number " { $snippet "m" } " by " { $snippet "s" } " bits to the left, wrapping around after 64 bits." }
-{ $examples
+{ $examples
{ $example "USING: math.bitwise prettyprint ;"
"HEX: 1 10 bitroll-64 .h"
"400"
{ $description "Clears the bits in " { $snippet "x" } " if they are set in the mask " { $snippet "n" } "." }
{ $examples
{ $example "USING: math.bitwise kernel prettyprint ;"
- "HEX: ff HEX: 0f unmask .h"
+ "HEX: ff HEX: 0f unmask .h"
"f0"
}
} ;
{ $description "Tests whether unmasking the bits in " { $snippet "x" } " would return an integer greater than zero." }
{ $examples
{ $example "USING: math.bitwise kernel prettyprint ;"
- "HEX: ff HEX: 0f unmask? ."
+ "HEX: ff HEX: 0f unmask? ."
"t"
}
} ;
}
{ $description "Wraps an integer " { $snippet "m" } " by modding it by " { $snippet "n" } ". This word is uses bitwise arithmetic and does not actually call the modulus word, and as such can only mod by powers of two." }
{ $examples "Equivalent to modding by 8:"
- { $example
+ { $example
"USING: math.bitwise prettyprint ;"
"HEX: ffff 8 wrap .h"
"7"
HELP: assoc-diff
{ $values { "assoc1" assoc } { "assoc2" assoc } { "diff" "a new assoc" } }
-{ $description "Outputs an assoc consisting of all entries from " { $snippet "assoc1" } " whose key is not contained in " { $snippet "assoc2" } "." }
+{ $description "Outputs an assoc consisting of all entries from " { $snippet "assoc1" } " whose key is not contained in " { $snippet "assoc2" } "." }
;
HELP: assoc-diff!
{ "assoc" assoc }
{ "keys" sequence } { "values" sequence } }
{ $description "Outputs an array of keys and an array of values of the input " { $snippet "assoc" } "." }
-{ $examples
+{ $examples
{ $example "USING: prettyprint assocs kernel ;"
"{ { 1 4 } { 2 5 } { 3 6 } } unzip [ . ] bi@"
- "{ 1 2 3 }\n{ 4 5 6 }"
+ "{ 1 2 3 }\n{ 4 5 6 }"
}
} ;
{ "keys" sequence } { "values" sequence }
{ "alist" "an array of key/value pairs" } }
{ $description "Combines two sequences pairwise into a single sequence of key/value pairs." }
-{ $examples
- { $example "" "USING: prettyprint assocs ;"
+{ $examples
+ { $example "USING: prettyprint assocs ;"
"{ 1 2 3 } { 4 5 6 } zip ."
"{ { 1 4 } { 2 5 } { 3 6 } }"
}