on master help sign in
Update 2c

Added `+fe` and the arms contained therein.

commit608b38330ebd1b6a40242cbccfcdb31e0a2c0e4b authorrmariani <robert@tlon.io> dateMon 18 Jun 2018, 11:20 (8 years ago) parent9f8665f
1 file changed+431
docs/hoon/library/2c.md+431
docs/hoon/library/2c.md+431
@@ -745,4 +745,435 @@ An atom.
745745
746746
747747
748+***
749+### `++fe`
750+
751+Modulo bloq
752+
753+Core that contains arms for `bloq` and modular integer operations.
754+
755+#### Accepts
756+
757+`a` is a `bloq`.
758+
759+#### Source
760+
761+ |_ a=bloq
762+
763+****
764+### `++dif`
765+
766+Produces the difference between two atoms in the modular basis
767+representation.
768+
769+#### Accepts
770+
771+`a` is a `bloq`.
772+
773+`b` is an atom.
774+
775+`c` is an atom.
776+
777+#### Produces
778+
779+A `@s`
780+
781+#### Source
782+
783+ ++ dif |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c))))
784+
785+#### Examples
786+
787+ > (~(dif fe 3) 63 64)
788+ 255
789+
790+ > (~(dif fe 3) 5 10)
791+ 251
792+
793+ > (~(dif fe 3) 0 1)
794+ 255
795+
796+ > (~(dif fe 0) 9 10)
797+ 1
798+
799+ > (~(dif fe 0) 9 11)
800+ 0
801+
802+ > (~(dif fe 0) 9 12)
803+ 1
804+
805+ > (~(dif fe 2) 9 12)
806+ 13
807+
808+ > (~(dif fe 2) 63 64)
809+ 15
810+
811+***
812+### `++inv`
813+
814+Inverse
815+
816+Inverts the order of the mowdular field.
817+
818+#### Accepts
819+
820+`b` is a `bloq`. (see [`++bloq`](../1c))
821+
822+#### Produces
823+
824+An atom.
825+
826+#### Source
827+
828+ ++ inv |=(b=@ (sub (dec out) (sit b)))
829+
830+#### Examples
831+
832+ > (~(inv fe 3) 255)
833+ 0
834+
835+ > (~(inv fe 3) 256)
836+ 255
837+
838+ > (~(inv fe 3) 0)
839+ 255
840+
841+ > (~(inv fe 3) 1)
842+ 254
843+
844+ > (~(inv fe 3) 2)
845+ 253
846+
847+ > (~(inv fe 3) 55)
848+ 200
849+
850+***
851+### `++net`
852+
853+Flip endianness
854+
855+Reverses bytes within a block.
856+
857+#### Accepts
858+
859+`b` is a `bloq`. (see [`++bloq`](../1c))
860+
861+#### Produces
862+
863+An atom.
864+
865+#### Source
866+
867+ ++ net |= b=@ ^- @
868+ => .(b (sit b))
869+ ?: (lte a 3)
870+ b
871+ =+ c=(dec a)
872+ %+ con
873+ (lsh c 1 $(a c, b (cut c [0 1] b)))
874+ $(a c, b (cut c [1 1] b))
875+
876+#### Examples
877+
878+ > (~(net fe 3) 64)
879+ 64
880+
881+ > (~(net fe 3) 128)
882+ 128
883+
884+ > (~(net fe 3) 255)
885+ 255
886+
887+ > (~(net fe 3) 256)
888+ 0
889+
890+ > (~(net fe 3) 257)
891+ 1
892+
893+ > (~(net fe 3) 500)
894+ 244
895+
896+ > (~(net fe 3) 511)
897+ 255
898+
899+ > (~(net fe 3) 512)
900+ 0
901+
902+ > (~(net fe 3) 513)
903+ 1
904+
905+ > (~(net fe 3) 0)
906+ 0
907+
908+ > (~(net fe 3) 1)
909+ 1
910+
911+ > (~(net fe 0) 1)
912+ 1
913+
914+ > (~(net fe 0) 2)
915+ 0
916+
917+ > (~(net fe 0) 3)
918+ 1
919+
920+ > (~(net fe 6) 1)
921+ 72.057.594.037.927.936
922+
923+ > (~(net fe 6) 2)
924+ 144.115.188.075.855.872
925+
926+ > (~(net fe 6) 3)
927+ 216.172.782.113.783.808
928+
929+ > (~(net fe 6) 4)
930+ 288.230.376.151.711.744
931+
932+ > (~(net fe 6) 5)
933+ 360.287.970.189.639.680
934+
935+***
936+### `++out`
937+
938+Max integer value
939+
940+Produces the maximum integer value that the current block can store; `2^a^a`.
941+
942+#### Accepts
943+
944+`a` is a `bloq`.
945+
946+#### Produces
947+
948+An atom.
949+
950+#### Source
951+
952+ ++ out (bex (bex a))
953+
954+#### Examples
955+
956+ > ~(out fe 0)
957+ 2
958+
959+ > ~(out fe 1)
960+ 4
961+
962+ > ~(out fe 2)
963+ 16
964+
965+ > ~(out fe 3)
966+ 256
967+
968+ > ~(out fe 4)
969+ 65.536
970+
971+ > ~(out fe 10)
972+ \/179.769.313.486.231.590.772.930.519.078.902.473.361.797.697.894.230.657.273\/
973+ .430.081.157.732.675.805.500.963.132.708.477.322.407.536.021.120.113.879.87
974+ 1.393.357.658.789.768.814.416.622.492.847.430.639.474.124.377.767.893.424.8
975+ 65.485.276.302.219.601.246.094.119.453.082.952.085.005.768.838.150.682.342.
976+ 462.881.473.913.110.540.827.237.163.350.510.684.586.298.239.947.245.938.479
977+ .716.304.835.356.329.624.224.137.216
978+ \/ \/
979+
980+***
981+### `++rol`
982+
983+Roll left
984+
985+Rolls `d` to the left by `c` `b`-sized blocks.
986+
987+#### Accepts
988+
989+`a` is a `bloq`.
990+
991+`b` is a `bloq`.
992+
993+`c` is an atom.
994+
995+`d` is an atom.
996+
997+#### Produces
998+
999+An atom.
1000+
1001+#### Source
1002+
1003+ ++ rol |= [b=bloq c=@ d=@] ^- @
1004+ =+ e=(sit d)
1005+ =+ f=(bex (sub a b))
1006+ =+ g=(mod c f)
1007+ (sit (con (lsh b g e) (rsh b (sub f g) e)))
1008+
1009+#### Examples
1010+
1011+ > `@ux`(~(rol fe 6) 4 3 0xabac.dedf.1213)
1012+ 0x1213.0000.abac.dedf
1013+
1014+ > `@ux`(~(rol fe 6) 4 2 0xabac.dedf.1213)
1015+ 0xdedf.1213.0000.abac
1016+
1017+ > `@t`(~(rol fe 5) 3 1 'dfgh')
1018+ 'hdfg'
1019+
1020+ > `@t`(~(rol fe 5) 3 2 'dfgh')
1021+ 'ghdf'
1022+
1023+ > `@t`(~(rol fe 5) 3 0 'dfgh')
1024+ 'dfgh'
1025+
1026+***
1027+### `++ror`
1028+
1029+Roll right
1030+
1031+Rolls `d` to the right by `c` `b`-sized blocks.
1032+
1033+#### Accepts
1034+
1035+`a` is a `bloq`.
1036+
1037+`b` is a `bloq`.
1038+
1039+`c` is an atom.
1040+
1041+`d` is an atom.
1042+
1043+#### Produces
1044+
1045+An atom.
1046+
1047+#### Source
1048+
1049+ ++ ror |= [b=bloq c=@ d=@] ^- @
1050+ =+ e=(sit d)
1051+ =+ f=(bex (sub a b))
1052+ =+ g=(mod c f)
1053+ (sit (con (rsh b g e) (lsh b (sub f g) e)))
1054+
1055+
1056+#### Examples
1057+
1058+ > `@ux`(~(ror fe 6) 4 1 0xabac.dedf.1213)
1059+ 0x1213.0000.abac.dedf
1060+
1061+ > `@ux`(~(ror fe 6) 3 5 0xabac.dedf.1213)
1062+ 0xacde.df12.1300.00ab
1063+
1064+ > `@ux`(~(ror fe 6) 3 3 0xabac.dedf.1213)
1065+ 0xdf12.1300.00ab.acde
1066+
1067+ > `@t`(~(rol fe 5) 3 0 'hijk')
1068+ 'hijk'
1069+
1070+ > `@t`(~(rol fe 5) 3 1 'hijk')
1071+ 'khij'
1072+
1073+ > `@t`(~(rol fe 5) 3 2 'hijk')
1074+ 'jkhi'
1075+
1076+***
1077+### `++sit`
1078+
1079+Enforce modulo
1080+
1081+Produces an atom in the current modular block representation.
1082+
1083+#### Accepts
1084+
1085+`a` is a `bloq`.
1086+
1087+`b` is an atom.
1088+
1089+#### Produces
1090+
1091+An atom.
1092+
1093+#### Source
1094+
1095+ ++ sit |=(b=@ (end a 1 b))
1096+
1097+#### Examples
1098+
1099+ > (~(sit fe 3) 255)
1100+ 255
1101+
1102+ > (~(sit fe 3) 256)
1103+ 0
1104+
1105+ > (~(sit fe 3) 257)
1106+ 1
1107+
1108+ > (~(sit fe 2) 257)
1109+ 1
1110+
1111+ > (~(sit fe 2) 10.000)
1112+ 0
1113+
1114+ > (~(sit fe 2) 100)
1115+ 4
1116+
1117+ > (~(sit fe 2) 19)
1118+ 3
1119+
1120+ > (~(sit fe 2) 17)
1121+ 1
1122+
1123+ > (~(sit fe 0) 17)
1124+ 1
1125+
1126+ > (~(sit fe 0) 0)
1127+ 0
1128+
1129+ > (~(sit fe 0) 1)
1130+ 1
1131+
1132+***
1133+
1134+### `++sum`
1135+
1136+Sum
1137+
1138+Sums two numbers in this modular field.
1139+
1140+#### Accepts
1141+
1142+`a` is a `bloq`.
1143+
1144+`b` is an atom.
1145+
1146+`c` is an atom.
1147+
1148+#### Produces
1149+
1150+An atom.
1151+
1152+#### Source
1153+
1154+ ++ sum |=([b=@ c=@] (sit (add b c)))
1155+
1156+#### Examples
1157+
1158+ > (~(sum fe 3) 10 250)
1159+ 4
1160+
1161+ > (~(sum fe 0) 0 1)
1162+ 1
1163+
1164+ > (~(sum fe 0) 0 2)
1165+ 0
1166+
1167+ > (~(sum fe 2) 14 2)
1168+ 0
1169+
1170+ > (~(sum fe 2) 14 3)
1171+ 1
1172+
1173+ > (~(sum fe 4) 10.000 256)
1174+ 10.256
1175+
1176+ > (~(sum fe 4) 10.000 100.000)
1177+ 44.464
1178+
7481179***