diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/404.html b/404.html new file mode 100644 index 0000000..deee46d --- /dev/null +++ b/404.html @@ -0,0 +1,383 @@ + + + +
+ + + + + + + + + + + + + + + + +
+ Bases: List[A]
slist/__init__.py
94 + 95 + 96 + 97 + 98 + 99 + 100 + 101 + 102 + 103 + 104 + 105 + 106 + 107 + 108 + 109 + 110 + 111 + 112 + 113 + 114 + 115 + 116 + 117 + 118 + 119 + 120 + 121 + 122 + 123 + 124 + 125 + 126 + 127 + 128 + 129 + 130 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + 138 + 139 + 140 + 141 + 142 + 143 + 144 + 145 + 146 + 147 + 148 + 149 + 150 + 151 + 152 + 153 + 154 + 155 + 156 + 157 + 158 + 159 + 160 + 161 + 162 + 163 + 164 + 165 + 166 + 167 + 168 + 169 + 170 + 171 + 172 + 173 + 174 + 175 + 176 + 177 + 178 + 179 + 180 + 181 + 182 + 183 + 184 + 185 + 186 + 187 + 188 + 189 + 190 + 191 + 192 + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + 202 + 203 + 204 + 205 + 206 + 207 + 208 + 209 + 210 + 211 + 212 + 213 + 214 + 215 + 216 + 217 + 218 + 219 + 220 + 221 + 222 + 223 + 224 + 225 + 226 + 227 + 228 + 229 + 230 + 231 + 232 + 233 + 234 + 235 + 236 + 237 + 238 + 239 + 240 + 241 + 242 + 243 + 244 + 245 + 246 + 247 + 248 + 249 + 250 + 251 + 252 + 253 + 254 + 255 + 256 + 257 + 258 + 259 + 260 + 261 + 262 + 263 + 264 + 265 + 266 + 267 + 268 + 269 + 270 + 271 + 272 + 273 + 274 + 275 + 276 + 277 + 278 + 279 + 280 + 281 + 282 + 283 + 284 + 285 + 286 + 287 + 288 + 289 + 290 + 291 + 292 + 293 + 294 + 295 + 296 + 297 + 298 + 299 + 300 + 301 + 302 + 303 + 304 + 305 + 306 + 307 + 308 + 309 + 310 + 311 + 312 + 313 + 314 + 315 + 316 + 317 + 318 + 319 + 320 + 321 + 322 + 323 + 324 + 325 + 326 + 327 + 328 + 329 + 330 + 331 + 332 + 333 + 334 + 335 + 336 + 337 + 338 + 339 + 340 + 341 + 342 + 343 + 344 + 345 + 346 + 347 + 348 + 349 + 350 + 351 + 352 + 353 + 354 + 355 + 356 + 357 + 358 + 359 + 360 + 361 + 362 + 363 + 364 + 365 + 366 + 367 + 368 + 369 + 370 + 371 + 372 + 373 + 374 + 375 + 376 + 377 + 378 + 379 + 380 + 381 + 382 + 383 + 384 + 385 + 386 + 387 + 388 + 389 + 390 + 391 + 392 + 393 + 394 + 395 + 396 + 397 + 398 + 399 + 400 + 401 + 402 + 403 + 404 + 405 + 406 + 407 + 408 + 409 + 410 + 411 + 412 + 413 + 414 + 415 + 416 + 417 + 418 + 419 + 420 + 421 + 422 + 423 + 424 + 425 + 426 + 427 + 428 + 429 + 430 + 431 + 432 + 433 + 434 + 435 + 436 + 437 + 438 + 439 + 440 + 441 + 442 + 443 + 444 + 445 + 446 + 447 + 448 + 449 + 450 + 451 + 452 + 453 + 454 + 455 + 456 + 457 + 458 + 459 + 460 + 461 + 462 + 463 + 464 + 465 + 466 + 467 + 468 + 469 + 470 + 471 + 472 + 473 + 474 + 475 + 476 + 477 + 478 + 479 + 480 + 481 + 482 + 483 + 484 + 485 + 486 + 487 + 488 + 489 + 490 + 491 + 492 + 493 + 494 + 495 + 496 + 497 + 498 + 499 + 500 + 501 + 502 + 503 + 504 + 505 + 506 + 507 + 508 + 509 + 510 + 511 + 512 + 513 + 514 + 515 + 516 + 517 + 518 + 519 + 520 + 521 + 522 + 523 + 524 + 525 + 526 + 527 + 528 + 529 + 530 + 531 + 532 + 533 + 534 + 535 + 536 + 537 + 538 + 539 + 540 + 541 + 542 + 543 + 544 + 545 + 546 + 547 + 548 + 549 + 550 + 551 + 552 + 553 + 554 + 555 + 556 + 557 + 558 + 559 + 560 + 561 + 562 + 563 + 564 + 565 + 566 + 567 + 568 + 569 + 570 + 571 + 572 + 573 + 574 + 575 + 576 + 577 + 578 + 579 + 580 + 581 + 582 + 583 + 584 + 585 + 586 + 587 + 588 + 589 + 590 + 591 + 592 + 593 + 594 + 595 + 596 + 597 + 598 + 599 + 600 + 601 + 602 + 603 + 604 + 605 + 606 + 607 + 608 + 609 + 610 + 611 + 612 + 613 + 614 + 615 + 616 + 617 + 618 + 619 + 620 + 621 + 622 + 623 + 624 + 625 + 626 + 627 + 628 + 629 + 630 + 631 + 632 + 633 + 634 + 635 + 636 + 637 + 638 + 639 + 640 + 641 + 642 + 643 + 644 + 645 + 646 + 647 + 648 + 649 + 650 + 651 + 652 + 653 + 654 + 655 + 656 + 657 + 658 + 659 + 660 + 661 + 662 + 663 + 664 + 665 + 666 + 667 + 668 + 669 + 670 + 671 + 672 + 673 + 674 + 675 + 676 + 677 + 678 + 679 + 680 + 681 + 682 + 683 + 684 + 685 + 686 + 687 + 688 + 689 + 690 + 691 + 692 + 693 + 694 + 695 + 696 + 697 + 698 + 699 + 700 + 701 + 702 + 703 + 704 + 705 + 706 + 707 + 708 + 709 + 710 + 711 + 712 + 713 + 714 + 715 + 716 + 717 + 718 + 719 + 720 + 721 + 722 + 723 + 724 + 725 + 726 + 727 + 728 + 729 + 730 + 731 + 732 + 733 + 734 + 735 + 736 + 737 + 738 + 739 + 740 + 741 + 742 + 743 + 744 + 745 + 746 + 747 + 748 + 749 + 750 + 751 + 752 + 753 + 754 + 755 + 756 + 757 + 758 + 759 + 760 + 761 + 762 + 763 + 764 + 765 + 766 + 767 + 768 + 769 + 770 + 771 + 772 + 773 + 774 + 775 + 776 + 777 + 778 + 779 + 780 + 781 + 782 + 783 + 784 + 785 + 786 + 787 + 788 + 789 + 790 + 791 + 792 + 793 + 794 + 795 + 796 + 797 + 798 + 799 + 800 + 801 + 802 + 803 + 804 + 805 + 806 + 807 + 808 + 809 + 810 + 811 + 812 + 813 + 814 + 815 + 816 + 817 + 818 + 819 + 820 + 821 + 822 + 823 + 824 + 825 + 826 + 827 + 828 + 829 + 830 + 831 + 832 + 833 + 834 + 835 + 836 + 837 + 838 + 839 + 840 + 841 + 842 + 843 + 844 + 845 + 846 + 847 + 848 + 849 + 850 + 851 + 852 + 853 + 854 + 855 + 856 + 857 + 858 + 859 + 860 + 861 + 862 + 863 + 864 + 865 + 866 + 867 + 868 + 869 + 870 + 871 + 872 + 873 + 874 + 875 + 876 + 877 + 878 + 879 + 880 + 881 + 882 + 883 + 884 + 885 + 886 + 887 + 888 + 889 + 890 + 891 + 892 + 893 + 894 + 895 + 896 + 897 + 898 + 899 + 900 + 901 + 902 + 903 + 904 + 905 + 906 + 907 + 908 + 909 + 910 + 911 + 912 + 913 + 914 + 915 + 916 + 917 + 918 + 919 + 920 + 921 + 922 + 923 + 924 + 925 + 926 + 927 + 928 + 929 + 930 + 931 + 932 + 933 + 934 + 935 + 936 + 937 + 938 + 939 + 940 + 941 + 942 + 943 + 944 + 945 + 946 + 947 + 948 + 949 + 950 + 951 + 952 + 953 + 954 + 955 + 956 + 957 + 958 + 959 + 960 + 961 + 962 + 963 + 964 + 965 + 966 + 967 + 968 + 969 + 970 + 971 + 972 + 973 + 974 + 975 + 976 + 977 + 978 + 979 + 980 + 981 + 982 + 983 + 984 + 985 + 986 + 987 + 988 + 989 + 990 + 991 + 992 + 993 + 994 + 995 + 996 + 997 + 998 + 999 +1000 +1001 +1002 +1003 +1004 +1005 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1022 +1023 +1024 +1025 +1026 +1027 +1028 +1029 +1030 +1031 +1032 +1033 +1034 +1035 +1036 +1037 +1038 +1039 +1040 +1041 +1042 +1043 +1044 +1045 +1046 +1047 +1048 +1049 +1050 +1051 +1052 +1053 +1054 +1055 +1056 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 +1071 +1072 +1073 +1074 +1075 +1076 +1077 +1078 +1079 +1080 +1081 +1082 +1083 +1084 +1085 +1086 +1087 +1088 +1089 +1090 +1091 +1092 +1093 +1094 +1095 +1096 +1097 +1098 +1099 +1100 +1101 +1102 +1103 +1104 +1105 +1106 +1107 +1108 +1109 +1110 +1111 +1112 +1113 +1114 +1115 +1116 +1117 +1118 +1119 +1120 +1121 +1122 +1123 +1124 +1125 +1126 +1127 +1128 +1129 +1130 +1131 +1132 +1133 +1134 +1135 +1136 +1137 +1138 +1139 +1140 +1141 +1142 +1143 +1144 +1145 +1146 +1147 +1148 +1149 +1150 +1151 +1152 +1153 +1154 +1155 +1156 +1157 +1158 +1159 +1160 +1161 +1162 +1163 +1164 +1165 +1166 +1167 +1168 +1169 +1170 +1171 +1172 +1173 +1174 +1175 +1176 +1177 +1178 +1179 +1180 +1181 +1182 +1183 +1184 +1185 +1186 +1187 +1188 +1189 +1190 +1191 +1192 +1193 +1194 +1195 +1196 +1197 +1198 +1199 +1200 +1201 +1202 +1203 +1204 +1205 +1206 +1207 +1208 +1209 +1210 +1211 +1212 +1213 +1214 +1215 +1216 +1217 +1218 +1219 +1220 +1221 +1222 +1223 +1224 +1225 +1226 +1227 +1228 +1229 +1230 +1231 +1232 +1233 +1234 +1235 +1236 +1237 +1238 +1239 +1240 +1241 +1242 +1243 +1244 +1245 +1246 +1247 +1248 +1249 +1250 +1251 +1252 +1253 +1254 +1255 +1256 +1257 +1258 +1259 +1260 +1261 +1262 +1263 +1264 +1265 +1266 +1267 +1268 +1269 +1270 +1271 +1272 +1273 +1274 +1275 +1276 +1277 +1278 +1279 +1280 +1281 +1282 +1283 +1284 +1285 +1286 +1287 +1288 +1289 +1290 +1291 +1292 +1293 +1294 +1295 +1296 +1297 +1298 +1299 +1300 +1301 +1302 +1303 +1304 +1305 +1306 +1307 +1308 +1309 +1310 +1311 +1312 +1313 +1314 +1315 +1316 +1317 +1318 +1319 +1320 +1321 +1322 +1323 +1324 +1325 +1326 +1327 +1328 +1329 +1330 +1331 +1332 +1333 +1334 +1335 +1336 +1337 +1338 +1339 +1340 +1341 +1342 +1343 +1344 +1345 +1346 +1347 +1348 +1349 +1350 +1351 +1352 +1353 +1354 +1355 +1356 +1357 +1358 +1359 +1360 +1361 +1362 +1363 +1364 +1365 +1366 +1367 +1368 +1369 +1370 +1371 +1372 +1373 +1374 +1375 +1376 +1377 +1378 +1379 +1380 +1381 +1382 +1383 +1384 +1385 +1386 +1387 +1388 +1389 +1390 +1391 +1392 +1393 +1394 +1395 +1396 +1397 +1398 +1399 +1400 +1401 +1402 +1403 +1404 +1405 +1406 +1407 +1408 +1409 +1410 +1411 +1412 +1413 +1414 +1415 +1416 +1417 +1418 +1419 +1420 +1421 +1422 +1423 +1424 +1425 +1426 +1427 +1428 +1429 +1430 +1431 +1432 +1433 +1434 +1435 +1436 +1437 +1438 +1439 +1440 +1441 +1442 +1443 +1444 +1445 +1446 +1447 +1448 +1449 +1450 +1451 +1452 +1453 +1454 +1455 +1456 +1457 +1458 +1459 +1460 +1461 +1462 +1463 +1464 +1465 +1466 +1467 +1468 +1469 +1470 +1471 +1472 +1473 +1474 +1475 +1476 +1477 +1478 +1479 +1480 +1481 +1482 +1483 +1484 +1485 +1486 +1487 +1488 +1489 +1490 +1491 +1492 +1493 +1494 +1495 +1496 +1497 +1498 +1499 +1500 +1501 +1502 +1503 +1504 +1505 +1506 +1507 +1508 +1509 +1510 +1511 +1512 +1513 +1514 +1515 +1516 +1517 +1518 +1519 +1520 +1521 +1522 +1523 +1524 +1525 +1526 +1527 +1528 +1529 +1530 +1531 +1532 +1533 +1534 +1535 +1536 +1537 +1538 +1539 +1540 +1541 +1542 +1543 +1544 +1545 +1546 +1547 +1548 +1549 +1550 +1551 +1552 +1553 +1554 +1555 +1556 +1557 +1558 +1559 +1560 +1561 +1562 +1563 +1564 +1565 +1566 +1567 +1568 +1569 +1570 +1571 +1572 +1573 +1574 +1575 +1576 +1577 +1578 +1579 +1580 +1581 +1582 +1583 +1584 +1585 +1586 +1587 +1588 +1589 +1590 +1591 +1592 +1593 +1594 +1595 +1596 +1597 +1598 +1599 +1600 +1601 +1602 +1603 +1604 +1605 +1606 +1607 +1608 +1609 +1610 +1611 +1612 +1613 +1614 +1615 +1616 +1617 +1618 +1619 +1620 +1621 +1622 +1623 +1624 +1625 +1626 +1627 +1628 +1629 +1630 +1631 +1632 +1633 +1634 +1635 +1636 +1637 +1638 +1639 +1640 +1641 +1642 +1643 +1644 +1645 +1646 +1647 +1648 +1649 +1650 +1651 +1652 +1653 +1654 +1655 +1656 +1657 +1658 +1659 +1660 +1661 +1662 +1663 +1664 +1665 +1666 +1667 +1668 +1669 +1670 +1671 +1672 +1673 +1674 +1675 +1676 +1677 +1678 +1679 +1680 +1681 +1682 +1683 +1684 +1685 +1686 +1687 +1688 +1689 +1690 +1691 +1692 +1693 +1694 +1695 +1696 +1697 +1698 +1699 +1700 +1701 +1702 +1703 +1704 +1705 +1706 +1707 +1708 +1709 +1710 +1711 +1712 +1713 +1714 +1715 +1716 +1717 +1718 +1719 +1720 +1721 +1722 +1723 +1724 +1725 +1726 +1727 +1728 +1729 +1730 +1731 +1732 +1733 +1734 +1735 +1736 +1737 +1738 +1739 +1740 +1741 +1742 +1743 +1744 +1745 +1746 +1747 +1748 +1749 +1750 +1751 +1752 +1753 +1754 +1755 +1756 +1757 +1758 +1759 +1760 +1761 +1762 +1763 +1764 +1765 +1766 +1767 +1768 +1769 +1770 +1771 +1772 +1773 +1774 +1775 +1776 +1777 +1778 +1779 +1780 +1781 +1782 +1783 +1784 +1785 +1786 +1787 +1788 +1789 +1790 +1791 +1792 +1793 +1794 +1795 +1796 +1797 +1798 +1799 +1800 +1801 +1802 +1803 +1804 +1805 +1806 +1807 +1808 +1809 +1810 +1811 +1812 +1813 +1814 +1815 +1816 +1817 +1818 +1819 +1820 +1821 +1822 +1823 +1824 +1825 +1826 +1827 +1828 +1829 +1830 +1831 +1832 +1833 +1834 +1835 +1836 +1837 +1838 +1839 +1840 +1841 +1842 +1843 +1844 +1845 +1846 +1847 +1848 +1849 +1850 +1851 +1852 +1853 +1854 +1855 +1856 +1857 +1858 +1859 +1860 +1861 +1862 +1863 +1864 +1865 +1866 +1867 +1868 +1869 +1870 +1871 +1872 +1873 +1874 +1875 +1876 +1877 +1878 +1879 +1880 +1881 +1882 +1883 +1884 +1885 +1886 +1887 +1888 +1889 +1890 +1891 +1892 +1893 +1894 +1895 +1896 +1897 +1898 +1899 +1900 +1901 +1902 +1903 +1904 +1905 +1906 +1907 +1908 +1909 +1910 +1911 +1912 +1913 +1914 +1915 +1916 +1917 +1918 +1919 +1920 +1921 +1922 +1923 +1924 +1925 +1926 +1927 +1928 +1929 +1930 +1931 +1932 +1933 +1934 +1935 +1936 +1937 +1938 +1939 +1940 +1941 +1942 +1943 +1944 +1945 +1946 +1947 +1948 +1949 +1950 +1951 +1952 +1953 +1954 +1955 +1956 +1957 +1958 +1959 +1960 +1961 +1962 +1963 +1964 +1965 +1966 +1967 +1968 +1969 +1970 +1971 +1972 +1973 +1974 +1975 +1976 +1977 +1978 +1979 +1980 +1981 +1982 +1983 +1984 +1985 +1986 +1987 +1988 +1989 +1990 +1991 +1992 +1993 +1994 +1995 +1996 +1997 +1998 +1999 +2000 +2001 +2002 +2003 +2004 +2005 +2006 +2007 +2008 +2009 +2010 +2011 +2012 +2013 +2014 +2015 +2016 +2017 +2018 +2019 +2020 +2021 +2022 +2023 +2024 +2025 +2026 +2027 +2028 +2029 +2030 +2031 +2032 +2033 +2034 +2035 +2036 +2037 +2038 +2039 +2040 +2041 +2042 +2043 +2044 +2045 +2046 +2047 +2048 +2049 +2050 +2051 +2052 +2053 +2054 +2055 +2056 +2057 +2058 +2059 +2060 +2061 +2062 +2063 +2064 +2065 +2066 +2067 +2068 +2069 +2070 +2071 +2072 +2073 +2074 +2075 +2076 +2077 +2078 +2079 +2080 +2081 +2082 +2083 +2084 +2085 +2086 +2087 +2088 +2089 +2090 +2091 +2092 +2093 +2094 +2095 +2096 +2097 +2098 +2099 +2100 +2101 +2102 +2103 +2104 +2105 +2106 +2107 +2108 +2109 +2110 +2111 +2112 +2113 |
|
property
+
+
+¶property
+
+
+¶property
+
+
+¶property
+
+
+¶property
+
+
+¶property
+
+
+¶staticmethod
+
+
+¶one(element: A) -> Slist[A]
+
Create a new Slist with a single element.
+element : A + The element to create the list with
+Slist[A] + A new Slist containing only the given element
+++ +++++Slist.one(5) +Slist([5])
+
slist/__init__.py
staticmethod
+
+
+¶one_option(element: Optional[A]) -> Slist[A]
+
Create a Slist with one element if it exists, otherwise empty list.
+Equal to Slist.one(element).flatten_option()
element : Optional[A] + The element to create the list with, if it exists
+Slist[A] + A new Slist containing the element if it exists, otherwise empty
+++ +++++Slist.one_option(5) +Slist([5]) +Slist.one_option(None) +Slist([])
+
slist/__init__.py
Check if any element satisfies the predicate.
+predicate : Callable[[A], bool] + Function that takes an element and returns True/False
+bool + True if any element satisfies the predicate, False otherwise
+++ +++++Slist([1, 2, 3, 4]).any(lambda x: x > 3) +True +Slist([1, 2, 3]).any(lambda x: x > 3) +False
+
slist/__init__.py
Check if all elements satisfy the predicate.
+predicate : Callable[[A], bool] + Function that takes an element and returns True/False
+bool + True if all elements satisfy the predicate, False otherwise
+++ +++++Slist([2, 4, 6]).all(lambda x: x % 2 == 0) +True +Slist([2, 3, 4]).all(lambda x: x % 2 == 0) +False
+
slist/__init__.py
filter(predicate: Callable[[A], bool]) -> Slist[A]
+
Create a new Slist with only elements that satisfy the predicate.
+predicate : Callable[[A], bool] + Function that takes an element and returns True/False
+Slist[A] + A new Slist containing only elements that satisfy the predicate
+++ +++++Slist([1, 2, 3, 4]).filter(lambda x: x % 2 == 0) +Slist([2, 4])
+
slist/__init__.py
map(func: Callable[[A], B]) -> Slist[B]
+
Transform each element using the given function.
+func : Callable[[A], B] + Function to apply to each element
+Slist[B] + A new Slist with transformed elements
+++ +++++Slist([1, 2, 3]).map(lambda x: x * 2) +Slist([2, 4, 6])
+
slist/__init__.py
product(other: Sequence[B]) -> Slist[Tuple[A, B]]
+
Compute the cartesian product with another sequence.
+other : Sequence[B] + The sequence to compute the product with
+Slist[Tuple[A, B]] + A new Slist containing tuples of all combinations
+++ +++++Slist([1, 2]).product(['a', 'b']) +Slist([(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b')])
+
slist/__init__.py
map_2(func: Callable[[B, C], D]) -> Slist[D]
+
Map a function over a sequence of 2-tuples.
+func : Callable[[B, C], D] + Function that takes two arguments and returns a value
+Slist[D] + A new Slist with the results of applying func to each tuple
+++ +++++pairs = Slist([(1, 2), (3, 4)]) +pairs.map_2(lambda x, y: x + y) +Slist([3, 7])
+
slist/__init__.py
map_enumerate(func: Callable[[int, A], B]) -> Slist[B]
+
Map a function over the list with indices.
+func : Callable[[int, A], B] + Function that takes an index and value and returns a new value
+Slist[B] + A new Slist with the results of applying func to each (index, value) pair
+++ +++++Slist(['a', 'b', 'c']).map_enumerate(lambda i, x: f"{i}:{x}") +Slist(['0:a', '1:b', '2:c'])
+
slist/__init__.py
flatten_option() -> Slist[B]
+
Remove None values from a sequence of optional values.
+self : Sequence[Optional[B]] + A sequence containing optional values
+Slist[B] + A new Slist with all non-None values
+++ +++++Slist([1, None, 3, None, 5]).flatten_option() +Slist([1, 3, 5])
+
slist/__init__.py
flat_map_option(func: Callable[[A], Optional[B]]) -> Slist[B]
+
Apply a function that returns optional values and filter out Nones.
+func : Callable[[A], Optional[B]] + Function that takes a value and returns an optional value
+Slist[B] + A new Slist with all non-None results of applying func
+++ +++++def safe_sqrt(x: float) -> Optional[float]: +... return x ** 0.5 if x >= 0 else None +Slist([4, -1, 9, -4, 16]).flat_map_option(safe_sqrt) +Slist([2.0, 3.0, 4.0])
+
slist/__init__.py
upsample_if(predicate: Callable[[A], bool], upsample_by: int) -> Slist[A]
+
Repeat elements that satisfy a predicate.
+predicate : Callable[[A], bool] + Function that determines which elements to upsample +upsample_by : int + Number of times to repeat each matching element
+Slist[A] + A new Slist with matching elements repeated
+++ +++++numbers = Slist([1, 2, 3, 4]) +numbers.upsample_if(lambda x: x % 2 == 0, upsample_by=2) +Slist([1, 2, 2, 3, 4, 4])
+
slist/__init__.py
flatten_list() -> Slist[B]
+
Flatten a sequence of sequences into a single list.
+self : Sequence[Sequence[B]] + A sequence of sequences to flatten
+Slist[B] + A new Slist with all elements from all sequences
+++ +++++nested = Slist([[1, 2], [3, 4], [5, 6]]) +nested.flatten_list() +Slist([1, 2, 3, 4, 5, 6])
+
slist/__init__.py
enumerated() -> Slist[Tuple[int, A]]
+
Create a list of tuples containing indices and values.
+Slist[Tuple[int, A]] + A new Slist of (index, value) tuples
+++ +++++Slist(['a', 'b', 'c']).enumerated() +Slist([(0, 'a'), (1, 'b'), (2, 'c')])
+
slist/__init__.py
shuffle(seed: Optional[str] = None) -> Slist[A]
+
Create a new randomly shuffled list.
+seed : Optional[str], optional + Random seed for reproducibility, by default None
+Slist[A] + A new Slist with elements in random order
+++ +++++Slist([1, 2, 3, 4]).shuffle(seed="42") # Reproducible shuffle +Slist([2, 4, 1, 3])
+
slist/__init__.py
Randomly select an element from the list.
+seed : Optional[str], optional + Random seed for reproducibility, by default None +weights : Optional[List[int]], optional + List of weights for weighted random selection, by default None
+A + A randomly selected element
+++ +++++Slist([1, 2, 3, 4]).choice(seed="42") # Reproducible choice +2 +Slist([1, 2, 3]).choice(weights=[1, 2, 1]) # Weighted choice +2 # More likely to select 2 due to higher weight
+
slist/__init__.py
sample(n: int, seed: Optional[str] = None) -> Slist[A]
+
Randomly sample n elements from the list without replacement.
+n : int + Number of elements to sample +seed : Optional[str], optional + Random seed for reproducibility, by default None
+Slist[A] + A new Slist with n randomly selected elements
+++ +++++Slist([1, 2, 3, 4, 5]).sample(3, seed="42") +Slist([2, 4, 1])
+
slist/__init__.py
for_each(func: Callable[[A], None]) -> Slist[A]
+
Apply a side-effect function to each element and return the original list.
+func : Callable[[A], None] + Function to apply to each element for its side effects
+Slist[A] + The original list, unchanged
+++ +++++nums = Slist([1, 2, 3]) +nums.for_each(print) # Prints each number +1 +2 +3 +nums # Original list is unchanged +Slist([1, 2, 3])
+
slist/__init__.py
Group elements by a key function.
+key : Callable[[A], CanHash] + Function to compute the group key for each element
+Slist[Group[CanHash, Slist[A]]] + A new Slist of Groups, where each Group contains: + - key: The grouping key + - values: Slist of elements in that group
+++ +++++numbers = Slist([1, 2, 3, 4]) +groups = numbers.group_by(lambda x: x % 2) # Group by even/odd +groups.map(lambda g: (g.key, list(g.values))) +Slist([(1, [1, 3]), (0, [2, 4])])
+
slist/__init__.py
ungroup() -> Slist[C]
+
Convert a list of groups back into a flat list of values.
+self : Slist[Group[Any, Slist[C]]] | Slist[Group[Any, Sequence[C]]] + A list of groups to ungroup
+Slist[C] + A flat list containing all values from all groups
+++ +++++groups = Slist([Group(0, [1, 2]), Group(1, [3, 4])]) +groups.ungroup() +Slist([1, 2, 3, 4])
+
slist/__init__.py
Apply a function to the values of each group.
+func : Callable[[Slist[C]], D] + Function to apply to each group's values
+Slist[Group[B, D]] + A new list of groups with transformed values
+++ +++++groups = Slist([1, 2, 3, 4]).group_by(lambda x: x % 2) +groups.map_on_group_values(lambda values: sum(values)) +Slist([Group(key=1, values=4), Group(key=0, values=6)])
+
slist/__init__.py
Apply a function to each element in each group's values.
+func : Callable[[B], C] + Function to apply to each element in each group's values
+Slist[Group[A, Sequence[C]]] + A new list of groups with transformed elements
+++ +++++groups = Slist([Group(1, [1, 2]), Group(2, [3, 4])]) +groups.map_on_group_values_list(lambda x: x * 2) +Slist([Group(1, [2, 4]), Group(2, [6, 8])])
+
slist/__init__.py
Transforms a Slist of key value pairs to a dictionary
+++++++Slist([(1, Slist([1, 1])), (2, Slist([2, 2])])).to_dict()
+
++ +++++Slist([1, 1, 2, 2]).group_by(lambda x: x).to_dict()
+
slist/__init__.py
staticmethod
+
+
+¶from_dict(a_dict: Dict[CanHash, A]) -> Slist[Tuple[CanHash, A]]
+
Convert a dictionary to a Slist of tuple values.
+a_dict : Dict[CanHash, A] + Dictionary to convert
+Slist[Tuple[CanHash, A]] + List of key-value tuples from the dictionary
+++ +++++Slist.from_dict({1: 'a', 2: 'b'}) +Slist([(1, 'a'), (2, 'b')])
+
slist/__init__.py
for_each_enumerate(func: Callable[[int, A], None]) -> Slist[A]
+
Apply a side-effect function to each element with its index.
+func : Callable[[int, A], None] + Function taking an index and value, applied for side effects
+Slist[A] + The original list, unchanged
+++ +++++nums = Slist(['a', 'b', 'c']) +nums.for_each_enumerate(lambda i, x: print(f"{i}: {x}")) +0: a +1: b +2: c +nums # Original list is unchanged +Slist(['a', 'b', 'c'])
+
slist/__init__.py
Get the maximum element if it exists.
+Optional[CanCompare] + Maximum element, or None if list is empty
+++ +++++Slist([1, 3, 2]).max_option() +3 +Slist([]).max_option() +None
+
slist/__init__.py
Get the element with maximum value by key function.
+key : Callable[[A], CanCompare] + Function to compute comparison value for each element
+Optional[A] + Element with maximum key value, or None if list is empty
+++ +++++Slist(['a', 'bbb', 'cc']).max_by(len) +'bbb' +Slist([]).max_by(len) +None
+
slist/__init__.py
Get maximum element using custom ordering function.
+ordering : Callable[[A, A], bool] + Function that returns True if first argument should be considered larger
+Optional[A] + Maximum element by ordering, or None if list is empty
+++ +++++Custom ordering: consider numbers closer to 10 as "larger"¶
+nums = Slist([1, 5, 8, 15]) +nums.max_by_ordering(lambda x, y: abs(x-10) < abs(y-10)) +8
+
slist/__init__.py
Get the minimum element if it exists.
+Optional[CanCompare] + Minimum element, or None if list is empty
+++ +++++Slist([3, 1, 2]).min_option() +1 +Slist([]).min_option() +None
+
slist/__init__.py
Get the element with minimum value by key function.
+key : Callable[[A], CanCompare] + Function to compute comparison value for each element
+Optional[A] + Element with minimum key value, or None if list is empty
+++ +++++Slist(['aaa', 'b', 'cc']).min_by(len) +'b' +Slist([]).min_by(len) +None
+
slist/__init__.py
Get minimum element using default ordering.
+Optional[CanCompare] + Minimum element, or None if list is empty
+++ +++++Slist([3, 1, 2]).min_by_ordering() +1 +Slist([]).min_by_ordering() +None
+
slist/__init__.py
Get element at index with fallback value.
+index : int + Index to get element from +or_else : B + Value to return if index is out of bounds
+Union[A, B] + Element at index if it exists, otherwise or_else value
+++ +++++Slist([1, 2, 3]).get(1, -1) +2 +Slist([1, 2, 3]).get(5, -1) +-1
+
slist/__init__.py
Get element at index if it exists.
+index : int + Index to get element from
+Optional[A] + Element at index if it exists, otherwise None
+++ +++++Slist([1, 2, 3]).get_option(1) +2 +Slist([1, 2, 3]).get_option(5) +None
+
slist/__init__.py
pairwise() -> Slist[Tuple[A, A]]
+
Return overlapping pairs of consecutive elements.
+Slist[Tuple[A, A]] + List of tuples containing consecutive overlapping pairs
+++++++Slist([1, 2, 3, 4]).pairwise() +Slist([(1, 2), (2, 3), (3, 4)]) +Slist([1]).pairwise() +Slist([]) +Slist([]).pairwise() +Slist([])
+
Inspired by more-itertools pairwise function. Creates an iterator of +overlapping pairs from the input sequence.
+ +slist/__init__.py
print_length(printer: Callable[[str], None] = print, prefix: str = 'Slist Length: ') -> Slist[A]
+
Print the length of the list and return the original list.
+printer : Callable[[str], None], optional + Function to print the output, by default print +prefix : str, optional + Prefix string before the length, by default "Slist Length: "
+Slist[A] + The original list unchanged
+++ +++++Slist([1,2,3]).print_length() +Slist Length: 3 +Slist([1, 2, 3])
+
slist/__init__.py
Get the most common element or raise an exception.
+exception : Exception, optional + Exception to raise if no mode exists, by default RuntimeError("List is empty")
+A + Most frequent element
+Exception + If list is empty or has no unique mode
+++ +++++Slist([1, 2, 2, 3]).mode_or_raise() +2 +try: +... Slist([]).mode_or_raise() +... except RuntimeError as e: +... print(str(e)) +List is empty
+
slist/__init__.py
Get the first element or raise an exception.
+exception : Exception, optional + Exception to raise if list is empty, by default RuntimeError("List is empty")
+A + First element
+Exception + If list is empty
+++ +++++Slist([1, 2, 3]).first_or_raise() +1 +try: +... Slist([]).first_or_raise() +... except RuntimeError as e: +... print(str(e)) +List is empty
+
slist/__init__.py
Get the last element or raise an exception.
+exception : Exception, optional + Exception to raise if list is empty, by default RuntimeError("List is empty")
+A + Last element
+Exception + If list is empty
+++ +++++Slist([1, 2, 3]).last_or_raise() +3 +try: +... Slist([]).last_or_raise() +... except RuntimeError as e: +... print(str(e)) +List is empty
+
slist/__init__.py
Find first element that satisfies a predicate.
+predicate : Callable[[A], bool] + Function that returns True for the desired element
+Optional[A] + First matching element, or None if no match found
+++ +++++Slist([1, 2, 3, 4]).find_one(lambda x: x > 2) +3 +Slist([1, 2, 3]).find_one(lambda x: x > 5) +None
+
slist/__init__.py
Find index of first element that satisfies a predicate.
+predicate : Callable[[A], bool] + Function that returns True for the desired element
+Optional[int] + Index of first matching element, or None if no match found
+++ +++++Slist([1, 2, 3, 4]).find_one_idx(lambda x: x > 2) +2 +Slist([1, 2, 3]).find_one_idx(lambda x: x > 5) +None
+
slist/__init__.py
Find index of last element that satisfies a predicate.
+predicate : Callable[[A], bool] + Function that returns True for the desired element
+Optional[int] + Index of last matching element, or None if no match found
+++ +++++Slist([1, 2, 3, 2, 1]).find_last_idx(lambda x: x == 2) +3 +Slist([1, 2, 3]).find_last_idx(lambda x: x > 5) +None
+
slist/__init__.py
find_one_idx_or_raise(predicate: Callable[[A], bool], exception: Exception = RuntimeError('Failed to find predicate')) -> int
+
Find index of first element that satisfies a predicate or raise exception.
+predicate : Callable[[A], bool] + Function that returns True for the desired element +exception : Exception, optional + Exception to raise if no match found, by default RuntimeError("Failed to find predicate")
+int + Index of first matching element
+Exception + If no matching element is found
+++ +++++Slist([1, 2, 3, 4]).find_one_idx_or_raise(lambda x: x > 2) +2 +try: +... Slist([1, 2, 3]).find_one_idx_or_raise(lambda x: x > 5) +... except RuntimeError as e: +... print(str(e)) +Failed to find predicate
+
slist/__init__.py
find_last_idx_or_raise(predicate: Callable[[A], bool], exception: Exception = RuntimeError('Failed to find predicate')) -> int
+
Find index of last element that satisfies a predicate or raise exception.
+predicate : Callable[[A], bool] + Function that returns True for the desired element +exception : Exception, optional + Exception to raise if no match found, by default RuntimeError("Failed to find predicate")
+int + Index of last matching element
+Exception + If no matching element is found
+++ +++++Slist([1, 2, 3, 2, 1]).find_last_idx_or_raise(lambda x: x == 2) +3 +try: +... Slist([1, 2, 3]).find_last_idx_or_raise(lambda x: x > 5) +... except RuntimeError as e: +... print(str(e)) +Failed to find predicate
+
slist/__init__.py
take_until_exclusive(predicate: Callable[[A], bool]) -> Slist[A]
+
Takes the first elements until the predicate is true. +Does not include the element that caused the predicate to return true.
+ +slist/__init__.py
take_until_inclusive(predicate: Callable[[A], bool]) -> Slist[A]
+
Takes the first elements until the predicate is true. +Includes the element that caused the predicate to return true.
+ +slist/__init__.py
sort_by(key: Callable[[A], CanCompare], reverse: bool = False) -> Slist[A]
+
Gets the element at the given percentile
+ +slist/__init__.py
Gets the median element
+ + +sort_by_penalise_duplicates(sort_key: Callable[[A], CanCompare], duplicate_key: Callable[[A], CanHash], reverse: bool = False) -> Slist[A]
+
Sort on a given sort key, but penalises duplicate_key such that they will be at the back of the list
+[1, 2, 3, 4, 5, 6, 1, 1]
+ +slist/__init__.py
shuffle_with_penalise_duplicates(duplicate_key: Callable[[A], CanHash], seed: Optional[str] = None) -> Slist[A]
+
Shuffle, but penalises duplicate_key such that they will be at the back of the list
+[6, 4, 1, 3, 5, 2, 1, 2, 1]
+ +slist/__init__.py
Groups the list into chunks of size size
slist/__init__.py
Returns a list of windows of size size
+If the list is too small or empty, returns an empty list
+Example:
++ +++++Slist([1, 2, 3, 4, 5]).window(3) +[[1, 2, 3], [2, 3, 4], [3, 4, 5]]
+Slist([1]).window(2) +[]
+
slist/__init__.py
distinct() -> Slist[CanHash]
+
Remove duplicate elements while preserving order.
+Slist[CanHash] + A new list with duplicates removed, maintaining original order
+++ +++++Slist([1, 2, 2, 3, 1, 4]).distinct() +Slist([1, 2, 3, 4])
+
slist/__init__.py
distinct_by(key: Callable[[A], CanHash]) -> Slist[A]
+
Remove duplicates based on a key function while preserving order.
+key : Callable[[A], CanHash] + Function to compute the unique key for each element
+Slist[A] + A new list with duplicates removed, maintaining original order
+++ +++++data = Slist([(1, 'a'), (2, 'b'), (1, 'c')]) +data.distinct_by(lambda x: x[0]) # Distinct by first element +Slist([(1, 'a'), (2, 'b')])
+
slist/__init__.py
Get the single unique item by a key function.
+Raises ValueError if the list is empty or contains multiple distinct items.
+key : Callable[[A], CanHash] + Function to compute the unique key for each element
+A + The single unique item
+ValueError + If the list is empty or contains multiple distinct items
+++ +++++Slist([1, 1, 1]).distinct_item_or_raise(lambda x: x) +1 +try: +... Slist([1, 2, 1]).distinct_item_or_raise(lambda x: x) +... except ValueError as e: +... print(str(e)) +Slist is not distinct [1, 2, 1]
+
slist/__init__.py
par_map(func: Callable[[A], B], executor: Executor) -> Slist[B]
+
Apply a function to each element in parallel using an executor.
+func : Callable[[A], B] + Function to apply to each element. Must be picklable if using ProcessPoolExecutor +executor : concurrent.futures.Executor + The executor to use for parallel execution
+Slist[B] + A new list with the results of applying func to each element
+++++++from concurrent.futures import ThreadPoolExecutor +with ThreadPoolExecutor() as exe: +... Slist([1, 2, 3]).par_map(lambda x: x * 2, exe) +Slist([2, 4, 6])
+
If using ProcessPoolExecutor, the function must be picklable (e.g., no lambda functions)
+ +slist/__init__.py
async
+
+
+¶par_map_async(func: Callable[[A], Awaitable[B]], max_par: int | None = None, tqdm: bool = False) -> Slist[B]
+
Asynchronously apply a function to each element with optional parallelism limit.
+func : Callable[[A], Awaitable[B]] + Async function to apply to each element +max_par : int | None, optional + Maximum number of parallel operations, by default None +tqdm : bool, optional + Whether to show a progress bar, by default False
+Slist[B] + A new Slist with the transformed elements
+++ +++++async def slow_double(x): +... await asyncio.sleep(0.1) +... return x * 2 +await Slist([1, 2, 3]).par_map_async(slow_double, max_par=2) +Slist([2, 4, 6])
+
slist/__init__.py
1547 +1548 +1549 +1550 +1551 +1552 +1553 +1554 +1555 +1556 +1557 +1558 +1559 +1560 +1561 +1562 +1563 +1564 +1565 +1566 +1567 +1568 +1569 +1570 +1571 +1572 +1573 +1574 +1575 +1576 +1577 +1578 +1579 +1580 +1581 +1582 +1583 +1584 +1585 +1586 +1587 +1588 +1589 +1590 +1591 +1592 +1593 +1594 +1595 +1596 +1597 +1598 +1599 +1600 +1601 +1602 +1603 +1604 +1605 +1606 +1607 +1608 +1609 +1610 +1611 |
|
async
+
+
+¶gather() -> Slist[B]
+
Gather and await all awaitables in the sequence.
+Slist[B] + A new Slist containing the awaited results
+++ +++++async def slow_value(x): +... await asyncio.sleep(0.1) +... return x +awaitables = [slow_value(1), slow_value(2), slow_value(3)] +await Slist(awaitables).gather() +Slist([1, 2, 3])
+
slist/__init__.py
filter_text_search(key: Callable[[A], str], search: List[str]) -> Slist[A]
+
Filter items based on text search terms.
+key : Callable[[A], str] + Function to extract searchable text from each item +search : List[str] + List of search terms to match (case-insensitive)
+Slist[A] + Items where key text matches any search term
+++ +++++items = Slist(['apple pie', 'banana bread', 'cherry cake']) +items.filter_text_search(lambda x: x, ['pie', 'cake']) +Slist(['apple pie', 'cherry cake'])
+
slist/__init__.py
Join string elements with a separator.
+sep : str + Separator to use between elements
+str + Joined string
+++ +++++Slist(['a', 'b', 'c']).mk_string(', ') +'a, b, c'
+
slist/__init__.py
Calculate the arithmetic mean of numeric values.
+Optional[float] + The average of all values, or None if the list is empty
+++ +++++Slist([1, 2, 3, 4]).average() +2.5 +Slist([]).average() +None
+
slist/__init__.py
Calculate the arithmetic mean of numeric values.
+float + The average of all values
+ValueError + If the list is empty
+++ +++++Slist([1, 2, 3, 4]).average_or_raise() +2.5 +try: +... Slist([]).average_or_raise() +... except ValueError as e: +... print(str(e)) +Cannot get average of empty list
+
slist/__init__.py
statistics_or_raise() -> AverageStats
+
Calculate comprehensive statistics for numeric values.
+AverageStats + Statistics including mean, standard deviation, and confidence intervals
+ValueError + If the list is empty
+++ +++++stats = Slist([1, 2, 3, 4, 5]).statistics_or_raise() +round(stats.average, 2) +3.0 +round(stats.standard_deviation, 2) +1.58
+
slist/__init__.py
Calculate the population standard deviation.
+Optional[float] + The standard deviation, or None if the list is empty
+++ +++++round(Slist([1, 2, 3, 4, 5]).standard_deviation(), 2) +1.58 +Slist([]).standard_deviation() +None
+
slist/__init__.py
standardize() -> Slist[float]
+
Standardize values to have mean 0 and standard deviation 1.
+Slist[float] + Standardized values, or empty list if input is empty
+++ +++++result = Slist([1, 2, 3, 4, 5]).standardize() +[round(x, 2) for x in result] # Rounded for display +[-1.26, -0.63, 0.0, 0.63, 1.26]
+
slist/__init__.py
Fold left operation (reduce) with initial accumulator.
+acc : B + Initial accumulator value +func : Callable[[B, A], B] + Function to combine accumulator with each element
+B + Final accumulated value
+++ +++++Slist([1, 2, 3, 4]).fold_left(0, lambda acc, x: acc + x) +10 +Slist(['a', 'b', 'c']).fold_left('', lambda acc, x: acc + x) +'abc'
+
slist/__init__.py
Fold right operation with initial accumulator.
+acc : B + Initial accumulator value +func : Callable[[A, B], B] + Function to combine each element with accumulator
+B + Final accumulated value
+++ +++++Slist([1, 2, 3]).fold_right('', lambda x, acc: str(x) + acc) +'321'
+
slist/__init__.py
Sums the elements of the sequence. Returns None if the sequence is empty.
+Optional[CanAdd] + The sum of all elements in the sequence, or None if the sequence is empty
+++ +++++Slist([1, 2, 3]).sum_option() +6 +Slist([]).sum_option() +None
+
slist/__init__.py
Sums the elements of the sequence. Raises an error if the sequence is empty.
+CanAdd + The sum of all elements in the sequence
+AssertionError + If the sequence is empty
+++ +++++Slist([1, 2, 3]).sum_or_raise() +6 +Slist([]).sum_or_raise() # doctest: +IGNORE_EXCEPTION_DETAIL +Traceback (most recent call last): +AssertionError: Cannot fold empty list
+
slist/__init__.py
Split list into two lists based on a predicate. Left list contains items that match the predicate.
+predicate : Callable[[A], bool] + Function to determine which list each element goes into
+Tuple[Slist[A], Slist[A]] + Tuple of (matching elements, non-matching elements)
+++ +++++evens, odds = Slist([1, 2, 3, 4, 5]).split_by(lambda x: x % 2 == 0) +evens +Slist([2, 4]) +odds +Slist([1, 3, 5])
+
slist/__init__.py
Split list into sublists based on a predicate.
+Slist[Slist[A]] + List of sublists
+++ +++++Slist([1, 2, 3, 4, 5]).split_on(lambda x: x % 2 == 0) +Slist([Slist([1, 3, 5]), Slist([2, 4])])
+
slist/__init__.py
Split list into two parts based on a proportion.
+left_proportion : float + Proportion of elements to include in first list (0 < left_proportion < 1)
+Tuple[Slist[A], Slist[A]] + Tuple of (first part, second part)
+++ +++++first, second = Slist([1, 2, 3, 4, 5]).split_proportion(0.6) +first +Slist([1, 2, 3]) +second +Slist([4, 5])
+
slist/__init__.py
Split list into n roughly equal parts.
+n : int + Number of parts to split into (must be positive)
+Slist[Slist[A]] + List of n sublists of roughly equal size
+++ +++++Slist([1, 2, 3, 4, 5]).split_into_n(2) +Slist([Slist([1, 3, 5]), Slist([2, 4])])
+
slist/__init__.py
copy() -> Slist[A]
+
Create a shallow copy of the list.
+Slist[A] + A new Slist with the same elements
+++ +++++original = Slist([1, 2, 3]) +copied = original.copy() +copied.append(4) +original # Original is unchanged +Slist([1, 2, 3])
+
slist/__init__.py
repeat_until_size(size: int) -> Optional[Slist[A]]
+
Repeat the list elements until reaching specified size.
+size : int + Target size (must be positive)
+Optional[Slist[A]] + New list with repeated elements, or None if input is empty
+++ +++++Slist([1, 2]).repeat_until_size(5) +Slist([1, 2, 1, 2, 1]) +Slist([]).repeat_until_size(3) +None
+
slist/__init__.py
repeat_until_size_or_raise(size: int) -> Slist[A]
+
Repeat the list elements until reaching specified size.
+size : int + Target size (must be positive)
+Slist[A] + New list with repeated elements
+AssertionError + If size is not positive +ValueError + If input list is empty
+++ +++++Slist([1, 2]).repeat_until_size_or_raise(5) +Slist([1, 2, 1, 2, 1])
+
slist/__init__.py
+ Bases: NamedTuple
, Generic[A_co, B_co]
This is a NamedTuple so that you can easily access the key and values
+ + + + + + +slist/__init__.py
dataclass
+
+
+¶slist/__init__.py
instance-attribute
+
+
+¶instance-attribute
+
+
+¶instance-attribute
+
+
+¶instance-attribute
+
+
+¶