1 / 28

COMS 4115

COMS 4115. Programming Languages &Translators Fall 2008 Prof. Stephen Edwards Mentor – Nalini Vasudevan. [K]AML : Array Manipulation Language. Kaori Fukuoka Ankush Goel Maninder Singh Mayur Lodha. Motivation. Array is a fundamental data structure Wide range of applications

doria
Download Presentation

COMS 4115

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMS 4115 Programming Languages &Translators Fall 2008 Prof. Stephen Edwards Mentor – Nalini Vasudevan

  2. [K]AML :Array Manipulation Language Kaori Fukuoka Ankush Goel Maninder Singh Mayur Lodha

  3. Motivation • Array is a fundamental data structure • Wide range of applications • Array manipulation an error prone part of algorithms • APL has complicated mathematical form and character set

  4. Overview • Expressive and concise Array Manipulation language • Rich set of operations on Arrays • Treats array as a primitive data type • Consistent structure

  5. Features • Data types • Unlimited size Arrays • Padding elements of Array • Dynamic length Arrays • Selection on demand

  6. Features • Operators • Control flow • Userdefined functions • Output

  7. Hello World program show(“Hello World !!!”);

  8. Array Declaration and Padding • [ ]a = {1,2,3,4,5,6,7,8,9,10}; • [ ][2]b = { {1,2}, {3,4}, {5}, {6} }; [ ][2]b = { {1,2}, {3,4}, {5,0}, {6,0} }

  9. Array Selection • [ ]a = {1,2,3,4,5,6,7,8,9,10}; • [ ]b = [0,3..6,8,9]a;[ ]b = {1,4,5,6,7,9,10};

  10. for Loop [ ]b = {1,4,5,6,7,9,10}; for (i = 0; i<#[ ]b; i++) { show( [i ]b , ” :: ”); } 1 :: 4 :: 5 :: 6 :: 7 :: 9 :: 10

  11. Conditional Statement ? (a > b) { show(“ a is greater than b”); } ! { show(“b is greater than a”); }

  12. Set Operations : Union • [ ][2]a = { {1,2}, {3,4}, {5,6} }; • [ ][2]b = { {5,6}, {7,8}, {9}, {10} }; • [ ][2]c = %+([ ][ ]a, [ ][ ]b); [ ][2]c = { {1,2}, {3,4}, {5,6}, {7,8}, {9,0}, {10,0} };

  13. Set Operations : Intersection • [ ][2]a = { {1,2}, {3,4}, {5,6} }; • [ ][2]b = { {5,6}, {7,8}, {9}, {10} }; • [ ][2]c = %=([ ][ ]a, [ ][ ]b); [ ][2]c = { {5,6} };

  14. Set Operations : Difference • [ ][2]a = { {1,2}, {3,4}, {5,6} }; • [ ][2]b = { {5,6}, {7,8}, {9}, {10} }; • [ ][2]c = %-([ ][ ]a, [ ][ ]b);[ ][2]c = { {1,2}, {3,4} };

  15. Reverse Array • [ ][2]b = { {5,6}, {7,8}, {9}, {10} }; • [ ][2]c = - [ ] [ ]b; [ ][2]c = { {10,0}, {9,0}, {7,8}, {5,6} };

  16. Copy Array • [ ][2]a = { {1,2}, {3,4}, {5,6} }; • [ ][2]b = [0,1][ ]a; [ ][2]b = { {1,2}, {3,4} };

  17. Size of Array • [ ][2]a = { {1,2}, {3,4}, {5,6} }; • #[ ][ ]a returns 6. • #[ ]a returns 3.

  18. Sum Array • [ ][2]a = { {1,2}, {3,4}, {5,6} }; • +[ ][ ]a returns 21. • +[0][ ]a returns 3. • +[ ][0]a returns 12.

  19. Concatenate Array • [ ][2]a = { {1,2}, {3,4}, {5,6} }; • [ ][2]b = { {5,6}, {7,8}, {9}, {10} }; • [ ][ ]a ++ [ ][ ]b; [ ][2]a = { {1,2}, {3,4}, {5,6}, {5,6}, {7,8}, {9,0}, {10,0} };

  20. Array Access • [ ][2]a = { {1,2}, {3,4}, {5,6} }; • [0][0]a returns 1. • [0][1]a returns 2.

  21. Insert into Array • [ ][2]b = { {1,2}, {3,4}, {5,6} }; • [ ][2]b <- { 7,8,9 }; [ ][ ]b = { {1,2}, {3,4}, {5,6}, {7,8}, {9,0} }

  22. Delete from Array • [ ][2]b = { {1,2}, {3,4}, {5,6} }; • [ ][ ]b -> 1; [ ][ ]b = { {3,4}, {5,6} }

  23. User defined Functions function add(a,b) { return a+b; }

  24. .kaml file Lexer Tokens Parser AST Exception Handling Symbol Table Interpreter Function Table Output Architecture

  25. Sample Program : Transpose [][]x for(i=0;i<#[]x;i++) { []temp = [i][]x; [][i]y = []temp; }

  26. Sample Program : Stack • push(c)[]b <- {c}; • pop() []b -> #[]b;

  27. Lessons Learned • Technical Aspects • Code Organization • Time management • Teamwork

  28. Future Enhancements • Multi Dimensional Array • More Data Types

More Related