Knowledge (XXG)

K (programming language)

Source 📝

1003: 374:
data objects, and array operations, such as sorting or reversing the order of an array. In addition, the language contains special operators that combine with primitive functions to perform types of iteration and recursion. As a result, complex and extended transformations of a dataset can be expressed as a chain of sub-expressions, with each link performing a segment of the calculation and passing the results to the next link in the chain.
1436: 25: 1426: 389:, with each of the ASCII symbols representing two or more distinct functions or operations. In a given expression, the actual function referenced is determined by the context. As a result, K expressions can be opaque and difficult to parse for humans. For example, in the following contrived expression the 373:
languages noted for concise and expressive syntax. They have simple rules of precedence based on right to left evaluation. The languages contain a rich set of primitive functions designed for processing arrays. These primitive functions include mathematical operations that work on arrays as whole
346:-like syntax. Since then, several financial products have been developed with K and kdb+. kdb+/tick and kdb+/taq were developed in 2001. kdb+, a 64-bit version of kdb+ was released in 2003 and kdb+/tick and kdb+/taq were released in 2004. kdb+ included 637:
If x is not prime then one of the values returned by the modulo operation will be 0 and consequently the minimal value of the list. If x is prime then the minimal value will be 1, because x mod 2 is 1 for any prime greater than 2.
429:
can be used in the same contexts where a data value can be used. Functions can be specified as anonymous expressions and used directly with other expressions. Function expressions are specified in K using
323:
In 1993, Whitney left Morgan Stanley and developed the first version of the K language. At the same time he formed Kx Systems to commercialize the product and signed an exclusive contract with
549:
K is an interpreted language where every statement is evaluated and its results displayed immediately. Literal expressions such as strings evaluate to themselves. Consequently, the
943: 1497: 1487: 1512: 1472: 1502: 42: 1462: 1440: 1107: 756: 347: 238: 1477: 936: 377:
Like APL, the primitive functions and operators are represented by single or double characters; however, unlike APL, K restricts itself to the
707: 1467: 1260: 1430: 706:
K is the foundation for a family of financial products. Kdb+ is an in-memory, column-based database with much of the same functions of a
1371: 1226: 1150: 1011: 258: 148: 89: 1482: 929: 108: 495:
In K, named functions are simply function expressions stored to a variable in the same way any data value is stored to a variable.
61: 434:. For example, in the following expression a quadratic expression is defined as a function and applied to the values 0 1 2 and 3: 1344: 1115: 1295: 977: 68: 1492: 1305: 832: 46: 550: 1188: 987: 422: 278: 226: 75: 691:' apply each value of the enumeration to the prime number function on the left. This will return a list of 0's and 1's. 320:. A+ had a smaller set of primitive functions and was designed for speed and to handle large sets of time series data. 1221: 792: 1061: 306: 218: 1254: 1080: 952: 726: 362: 274: 222: 57: 718:
and ksql, a query language with a syntax similar to SQL and designed for column based queries and array analysis.
35: 324: 1140: 1092: 750: 382: 414:
is rotation where the list on the right is rotated two times to the left producing the final result of 2 0 1.
1507: 1205: 966: 331: 290: 192: 136: 1131: 327:(UBS). For the next four years he developed various financial and trading applications using K for UBS. 1419: 1365: 1232: 426: 386: 366: 339: 281:. Advocates of the language emphasize its speed, facility in handling arrays, and expressive syntax. 254: 127: 541:
Functions can be passed as an argument to another function or returned as a result from a function.
273:, and other related financial products. The language, originally developed in 1993, is a variant of 82: 1331: 1053: 1002: 378: 1326: 418: 335: 313: 294: 155: 630:
x!/: performs modulo division between the original integer and each value in the truncated list.
1290: 738: 390: 132: 894: 1336: 1280: 992: 722: 1354: 1285: 982: 971: 410:
is enumeration and lists the integers less than 3, resulting in the list 0 1 2. The final
143: 302: 641:
The function below can be used to list all of the prime numbers between 1 and R with:
1456: 1392: 431: 370: 1310: 838: 585:@ uses the integer values on the right to index into the original list of strings. 385:). To allow for this, the set of primitive functions for K is smaller and heavily 1379: 1349: 1300: 317: 305:
developing financial applications. At Morgan Stanley, Whitney helped to develop
188: 183: 24: 889: 1210: 1183: 904: 582:> returns the indices that would sort a list of values in descending order. 350:, a language that merged the functions of the underlying K language and ksql. 289:
Before developing K, Arthur Whitney had worked extensively with APL, first at
262: 817: 1321: 298: 913: 899: 796: 406:
is modulo division that is performed on 7 and 4 resulting in 3. The next
270: 334:. In 1998, Kx Systems released kdb+, a database built on K. kdb was an 1215: 715: 1098: 559:
The following expression sorts a list of strings by their lengths:
266: 921: 734: 730: 309:, a variant of APL, to facilitate migrating APL applications from 1031: 907: 589:
A function to determine if a number is prime can be written as:
925: 1200: 852: 759:, the language of kdb+ and a new merged version of K and ksql. 711: 343: 310: 18: 627:
2_ drops the first two elements of the enumeration (0 and 1).
881: 697:
2_ drop the first two elements of the enumeration (0 and 1)
633:&/ find the minimum value of the list of modulo result. 575:
The expression is evaluated from right to left as follows:
694:& return the indices of the list where the value is 1. 353:
Whitney released a derivative of K called Shakti in 2018.
417:
The second core distinction of K is that functions are
242: 342:
database and included ksql, a query language with an
1273: 1247: 1170: 1163: 1139: 1130: 1052: 1019: 1010: 959: 579:#:'x returns the length of each word in the list x. 232: 212: 198: 182: 164: 154: 142: 126: 49:. Unsourced material may be challenged and removed. 777: 871: 330:The contract ended in 1997 when UBS merged with 203: 890:Overview of K (with a link to K reference card) 684:The expression is evaluated from right to left 624:!x enumerate the positive integers less than x. 620:The function is evaluated from right to left: 937: 257:processing programming language developed by 8: 265:. The language serves as the foundation for 121: 895:Dennis Shasha - K as a Prototyping Language 1167: 1136: 1016: 944: 930: 922: 120: 834:Q Language Widening the Appeal of Vectors 109:Learn how and when to remove this message 1498:Dynamically typed programming languages 1488:Proprietary database management systems 769: 688:!R enumerate the integers less than R. 1513:Programming languages created in 1993 708:relational database management system 402:Reading from right to left the first 7: 1425: 1237:Telecompute Integrated Systems, Inc. 831:Garland, Simon (December 28, 2004), 396:refers to three distinct functions: 47:adding citations to reliable sources 1227:Scientific Time Sharing Corporation 1151:Association for Computing Machinery 1473:Data-centric programming languages 14: 1503:High-level programming languages 1435: 1434: 1424: 1116:Polymorphic Programming Language 1001: 918:an open-source K3 implementation 23: 1463:APL programming language family 793:"Notation as a Tool of Thought" 753:, another APL-inspired language 34:needs additional citations for 721:Kdb+ is available for several 381:(as does another APL variant, 1: 1478:Dynamic programming languages 1189:Digital Equipment Corporation 269:, an in-memory, column-based 58:"K" programming language 1240:Time Sharing Resources (TSR) 1468:Array programming languages 1222:Science Research Associates 837:, Vector UK, archived from 361:K shares key features with 170:; 31 years ago 1529: 1255:Carnegie Mellon University 900:K by Arthur Whitney (2005) 818:"arthur bio and interview" 421:, a concept borrowed from 1405: 1388: 999: 325:Union Bank of Switzerland 277:and contains elements of 237: 217: 1483:Function-level languages 710:. The database supports 643: 591: 561: 497: 436: 1216:Micro Computer Machines 1156:British APL Association 1261:University of Maryland 1206:I. P. Sharp Associates 967:APL syntax and symbols 291:I. P. Sharp Associates 261:and commercialized by 1493:Programming languages 553:-program is trivial: 427:First-class functions 1420:Open-source software 1366:Edward H. Sussenguth 1233:Soliton Incorporated 1177:Analogic Corporation 741:(32-bit or 64-bit). 702:K financial products 316:to a network of Sun 43:improve this article 16:Programming language 419:first-class objects 379:ASCII character set 314:mainframe computers 165:First appeared 123: 1327:Kenneth E. Iverson 1315:Patrick E. Hagerty 841:on January 1, 2007 791:Iverson, Kenneth. 1450: 1449: 1401: 1400: 1376:William Yerazunis 1359:J. Henri Schueler 1318:Herbert Hellerman 1269: 1268: 1126: 1125: 723:operating systems 391:exclamation point 253:is a proprietary 248: 247: 184:Typing discipline 119: 118: 111: 93: 1520: 1438: 1437: 1428: 1427: 1337:Eugene McDonnell 1168: 1137: 1017: 1005: 993:Shared Variables 946: 939: 932: 923: 885: 884: 882:Official website 875: 874: 872:Official website 857: 856: 849: 843: 842: 828: 822: 821: 814: 808: 807: 805: 804: 795:. Archived from 788: 782: 781: 774: 680: 677: 674: 671: 668: 665: 662: 659: 656: 653: 650: 647: 616: 613: 610: 607: 604: 601: 598: 595: 571: 568: 565: 537: 534: 531: 528: 525: 522: 519: 516: 513: 510: 507: 504: 501: 491: 488: 485: 482: 479: 476: 473: 470: 467: 464: 461: 458: 455: 452: 449: 446: 443: 440: 413: 409: 405: 395: 365:. They are both 208: 205: 178: 176: 171: 144:Designed by 124: 114: 107: 103: 100: 94: 92: 51: 27: 19: 1528: 1527: 1523: 1522: 1521: 1519: 1518: 1517: 1453: 1452: 1451: 1446: 1423: 1397: 1384: 1296:Charles Brenner 1265: 1243: 1159: 1142: 1122: 1048: 1012:Implementations 1006: 997: 983:Iverson bracket 972:Direct function 955: 953:APL programming 950: 880: 879: 870: 869: 866: 861: 860: 851: 850: 846: 830: 829: 825: 816: 815: 811: 802: 800: 790: 789: 785: 776: 775: 771: 766: 747: 704: 682: 681: 678: 675: 672: 669: 666: 663: 660: 657: 654: 651: 648: 645: 618: 617: 614: 611: 608: 605: 602: 599: 596: 593: 573: 572: 569: 566: 563: 557: 556:"Hello world!" 547: 539: 538: 535: 532: 529: 526: 523: 520: 517: 514: 511: 508: 505: 502: 499: 493: 492: 489: 486: 483: 480: 477: 474: 471: 468: 465: 462: 459: 456: 453: 450: 447: 444: 441: 438: 411: 407: 403: 400: 393: 359: 340:column-oriented 301:, and later at 287: 202: 174: 172: 169: 149:Arthur Whitney 115: 104: 98: 95: 52: 50: 40: 28: 17: 12: 11: 5: 1526: 1524: 1516: 1515: 1510: 1505: 1500: 1495: 1490: 1485: 1480: 1475: 1470: 1465: 1455: 1454: 1448: 1447: 1445: 1444: 1415: 1413:= discontinued 1406: 1403: 1402: 1399: 1398: 1396: 1395: 1389: 1386: 1385: 1383: 1382: 1377: 1374: 1372:Arthur Whitney 1369: 1363: 1360: 1357: 1352: 1347: 1342: 1341:Robert Metzger 1339: 1334: 1329: 1324: 1319: 1316: 1313: 1308: 1303: 1298: 1293: 1288: 1283: 1277: 1275: 1271: 1270: 1267: 1266: 1264: 1263: 1258: 1251: 1249: 1245: 1244: 1242: 1241: 1238: 1235: 1230: 1224: 1219: 1213: 1208: 1203: 1198: 1195: 1192: 1186: 1181: 1178: 1174: 1172: 1165: 1161: 1160: 1158: 1157: 1154: 1147: 1145: 1134: 1128: 1127: 1124: 1123: 1121: 1120: 1112: 1111: 1110: 1096: 1090: 1084: 1077: 1071: 1058: 1056: 1050: 1049: 1047: 1046: 1040: 1035: 1027: 1023: 1021: 1014: 1008: 1007: 1000: 998: 996: 995: 990: 985: 980: 975: 969: 963: 961: 957: 956: 951: 949: 948: 941: 934: 926: 920: 919: 911: 902: 897: 892: 887: 877: 865: 864:External links 862: 859: 858: 844: 823: 809: 783: 768: 767: 765: 762: 761: 760: 754: 746: 743: 703: 700: 699: 698: 695: 692: 689: 644: 635: 634: 631: 628: 625: 592: 587: 586: 583: 580: 562: 555: 546: 543: 498: 437: 432:curly brackets 398: 358: 355: 303:Morgan Stanley 286: 283: 259:Arthur Whitney 246: 245: 235: 234: 230: 229: 215: 214: 210: 209: 200: 196: 195: 186: 180: 179: 166: 162: 161: 158: 152: 151: 146: 140: 139: 130: 117: 116: 31: 29: 22: 15: 13: 10: 9: 6: 4: 3: 2: 1525: 1514: 1511: 1509: 1508:1993 software 1506: 1504: 1501: 1499: 1496: 1494: 1491: 1489: 1486: 1484: 1481: 1479: 1476: 1474: 1471: 1469: 1466: 1464: 1461: 1460: 1458: 1443: 1442: 1433: 1432: 1422: 1421: 1416: 1414: 1411: 1408: 1407: 1404: 1394: 1393:Iverson Award 1391: 1390: 1387: 1381: 1378: 1375: 1373: 1370: 1367: 1364: 1361: 1358: 1356: 1353: 1351: 1348: 1346: 1343: 1340: 1338: 1335: 1333: 1332:Dick Lathwell 1330: 1328: 1325: 1323: 1320: 1317: 1314: 1312: 1309: 1307: 1304: 1302: 1299: 1297: 1294: 1292: 1289: 1287: 1284: 1282: 1279: 1278: 1276: 1272: 1262: 1259: 1256: 1253: 1252: 1250: 1246: 1239: 1236: 1234: 1231: 1228: 1225: 1223: 1220: 1217: 1214: 1212: 1209: 1207: 1204: 1202: 1199: 1196: 1193: 1190: 1187: 1185: 1182: 1179: 1176: 1175: 1173: 1169: 1166: 1164:Organizations 1162: 1155: 1152: 1149: 1148: 1146: 1144: 1138: 1135: 1133: 1129: 1118: 1117: 1113: 1109: 1105: 1102: 1101: 1100: 1097: 1094: 1091: 1088: 1085: 1083: 1082: 1078: 1076: 1072: 1069: 1068: 1064: 1060: 1059: 1057: 1055: 1051: 1044: 1041: 1039: 1036: 1034: 1033: 1028: 1025: 1024: 1022: 1018: 1015: 1013: 1009: 1004: 994: 991: 989: 986: 984: 981: 979: 976: 973: 970: 968: 965: 964: 962: 958: 954: 947: 942: 940: 935: 933: 928: 927: 924: 917: 916: 912: 910:for a K clone 909: 906: 903: 901: 898: 896: 893: 891: 888: 883: 878: 873: 868: 867: 863: 854: 848: 845: 840: 836: 835: 827: 824: 819: 813: 810: 799:on 2013-09-20 798: 794: 787: 784: 779: 773: 770: 763: 758: 755: 752: 749: 748: 744: 742: 740: 736: 732: 728: 724: 719: 717: 713: 709: 701: 696: 693: 690: 687: 686: 685: 642: 639: 632: 629: 626: 623: 622: 621: 590: 584: 581: 578: 577: 576: 560: 554: 552: 544: 542: 496: 435: 433: 428: 424: 420: 415: 397: 392: 388: 384: 380: 375: 372: 368: 364: 356: 354: 351: 349: 345: 341: 337: 333: 328: 326: 321: 319: 315: 312: 308: 304: 300: 296: 292: 284: 282: 280: 276: 272: 268: 264: 260: 256: 252: 244: 240: 236: 231: 228: 224: 220: 216: 213:Influenced by 211: 207: 201: 197: 194: 190: 187: 185: 181: 167: 163: 159: 157: 153: 150: 147: 145: 141: 138: 134: 131: 129: 125: 113: 110: 102: 91: 88: 84: 81: 77: 74: 70: 67: 63: 60: –  59: 55: 54:Find sources: 48: 44: 38: 37: 32:This article 30: 26: 21: 20: 1439: 1429: 1417: 1412: 1409: 1355:John Scholes 1311:Adin Falkoff 1286:Bob Bernecky 1143:associations 1141:Professional 1114: 1103: 1086: 1079: 1074: 1066: 1062: 1042: 1037: 1030: 914: 876:, Kx Systems 847: 839:the original 833: 826: 812: 801:. Retrieved 797:the original 786: 778:"Kx Systems" 772: 725:, including 720: 705: 683: 640: 636: 619: 588: 574: 567:@>#:' 558: 548: 540: 494: 416: 401: 376: 360: 352: 329: 322: 318:workstations 288: 250: 249: 105: 96: 86: 79: 72: 65: 53: 41:Please help 36:verification 33: 1380:Rodnay Zaks 1350:Alan Perlis 1345:Roger Moore 1301:Fred Brooks 1291:Larry Breed 1281:Phil Abrams 1197:Dyalog Ltd. 1194:DNA Systems 1045:→ NARS2000° 551:Hello world 371:interactive 367:interpreted 295:Ken Iverson 99:August 2011 1457:Categories 1211:Kx Systems 1184:CompuServe 1073:APLNext → 1026:Dyalog APL 978:Code pages 803:2015-02-23 764:References 387:overloaded 332:Swiss Bank 293:alongside 263:Kx Systems 233:Influenced 160:Kx Systems 137:functional 69:newspapers 1362:Bob Smith 1322:Roger Hui 1306:Jim Brown 1248:Education 1132:Community 1075:VisualAPL 1038:SHARP APL 336:in-memory 299:Roger Hui 156:Developer 1441:Category 1171:Business 1153:: SIGAPL 1054:Dialects 960:Features 853:"Shakti" 745:See also 545:Examples 357:Overview 271:database 128:Paradigm 1431:Commons 1410:Italics 1180:APL2000 1087:GNU APL 1029:APL2 → 739:Windows 727:Solaris 285:History 199:Website 189:dynamic 173: ( 83:scholar 1274:People 1229:(STSC) 886:, kdb+ 737:, and 716:SQL-92 676:'! 655:&/ 649:_& 597:&/ 487:'! 423:Scheme 399:2!!7!4 279:Scheme 243:Shakti 227:Scheme 193:strong 85:  78:  71:  64:  56:  1257:(CMU) 1218:(MCM) 1191:(DEC) 1119:(PPL) 1020:Major 974:(dfn) 735:macOS 731:Linux 255:array 133:array 90:JSTOR 76:books 1418:° = 1099:kdb+ 1043:NARS 1032:APLX 988:Rank 915:Kona 908:REPL 297:and 267:kdb+ 206:.com 175:1993 168:1993 62:news 1368:Jr. 1201:IBM 1081:ELI 712:SQL 661:!/: 603:!/: 363:APL 344:SQL 311:IBM 275:APL 223:APL 45:by 1459:: 1106:, 1067:A+ 1065:→ 905:oK 733:, 729:, 714:, 667:_! 609:_! 515:{( 506:25 439:{( 425:. 369:, 338:, 307:A+ 241:, 225:, 221:, 219:A+ 204:kx 191:, 135:, 1108:Q 1104:K 1095:° 1093:J 1089:° 1070:° 1063:A 945:e 938:t 931:v 855:. 820:. 806:. 780:. 757:Q 751:J 679:R 673:} 670:x 664:2 658:x 652:{ 646:2 615:} 612:x 606:2 600:x 594:{ 570:x 564:x 536:} 533:1 530:- 527:) 524:2 521:^ 518:x 512:: 509:f 503:: 500:a 490:4 484:} 481:1 478:+ 475:) 472:x 469:* 466:2 463:( 460:+ 457:) 454:2 451:^ 448:x 445:* 442:3 412:! 408:! 404:! 394:! 383:J 348:Q 251:K 239:Q 177:) 122:K 112:) 106:( 101:) 97:( 87:· 80:· 73:· 66:· 39:.

Index


verification
improve this article
adding citations to reliable sources
"K" programming language
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
Paradigm
array
functional
Designed by
Arthur Whitney
Developer
Typing discipline
dynamic
strong
kx.com
A+
APL
Scheme
Q
Shakti
array
Arthur Whitney
Kx Systems
kdb+

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.