{"title":"回溯","authors":"Christopher A. Welty, Louis J. Hoebel","doi":"10.1145/333175.333183","DOIUrl":null,"url":null,"abstract":"Iterating over the elements of an abstract collection is usu ally done in ML using a fold-like higher-order function provided by th e data structure. This article discusses a different paradigm of i teration based on purely functional, immutable cursors. Contrary to foldlike iterators, the iteration can be cleanly interrupted at any step. Contrary to imperative cursors (such as those found in C++ an d Java libraries) it is possible to backtrack the iterator to a previous step. Several ways to iterate over binary trees are examined a d close links with Gérard Huet’s Zipperare established. Incidentally, we show the well-known two-lists implementation of functio nal queues arising from a Zipper-based breadth-first traversal.","PeriodicalId":8272,"journal":{"name":"Appl. Intell.","volume":"28 1","pages":"60"},"PeriodicalIF":0.0000,"publicationDate":"1900-01-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"20","resultStr":"{\"title\":\"Backtracking\",\"authors\":\"Christopher A. Welty, Louis J. Hoebel\",\"doi\":\"10.1145/333175.333183\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"Iterating over the elements of an abstract collection is usu ally done in ML using a fold-like higher-order function provided by th e data structure. This article discusses a different paradigm of i teration based on purely functional, immutable cursors. Contrary to foldlike iterators, the iteration can be cleanly interrupted at any step. Contrary to imperative cursors (such as those found in C++ an d Java libraries) it is possible to backtrack the iterator to a previous step. Several ways to iterate over binary trees are examined a d close links with Gérard Huet’s Zipperare established. Incidentally, we show the well-known two-lists implementation of functio nal queues arising from a Zipper-based breadth-first traversal.\",\"PeriodicalId\":8272,\"journal\":{\"name\":\"Appl. Intell.\",\"volume\":\"28 1\",\"pages\":\"60\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"1900-01-01\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"20\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Appl. Intell.\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.1145/333175.333183\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Appl. Intell.","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/333175.333183","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
Iterating over the elements of an abstract collection is usu ally done in ML using a fold-like higher-order function provided by th e data structure. This article discusses a different paradigm of i teration based on purely functional, immutable cursors. Contrary to foldlike iterators, the iteration can be cleanly interrupted at any step. Contrary to imperative cursors (such as those found in C++ an d Java libraries) it is possible to backtrack the iterator to a previous step. Several ways to iterate over binary trees are examined a d close links with Gérard Huet’s Zipperare established. Incidentally, we show the well-known two-lists implementation of functio nal queues arising from a Zipper-based breadth-first traversal.