975:
The stream "Goodbye world!" is added to the text file written in the first command. The ";" implies the execution of the given commands in order, not simultaneously. So, the final content of the text file is:
171:
577:
append = reduce cons = (reduce cons ) (cons 1 (cons 2 nil)) = cons 1 (cons 2 )) (replacing cons by cons and nil by ) =
953:
the append redirect is the usage of ">>" for adding a stream to something, like in the following series of shell commands:
1000:
1088:
1098:
557:, from Hughes (1989:5-6), has the same semantics (by example) as the Scheme implementation above, for two arguments.
996:
1093:
1083:
392:
376:
142:
41:
550:
832:
185:
590:
564:
554:
59:
423:
1061:
658:, the push function is equivalent to the append method, and can be used in the following way.
1048:
823:
Note that when opening and closing file handles, one should always check the return value.
56:
20:
16:
Operation for concatenating linked lists or arrays in some high-level programming languages
8:
193:
156:
1036:
1025:
950:
435:
510:
This predicate can be used for appending, but also for picking lists apart. Calling
1017:
1008:
173:
elements. It may thus be a source of inefficiency if used injudiciously in code.
37:
768:
When opening a file, use the ">>" mode to append rather than over write.
384:
146:
221:. The following is a simple implementation in Scheme, for two arguments only:
141:
procedure must completely copy all of its arguments except the last, both its
1077:
1021:
30:
1040:
713:
The unshift function appends to the front of a list, rather than the end
380:
197:
67:
33:
212:
586:
541:
L = , R = ; L = , R = ; L = , R = ; L = , R =
396:
200:
of each argument (save the last), pointing it to the next list.
439:
404:
70:
as arguments, and returns the concatenation of these lists.
655:
568:
217:
593:
has the same effect as the Scheme implementation above:
159:
642:
This is essentially a reimplementation of
Haskell's
165:
318:Append can also be implemented using fold-right:
1075:
446:predicate, which can be implemented as follows:
571:constructs a list from two values or lists.
422:symbols to nondestructively concatenate a
1076:
1035:
995:
765:The end result is a list containing
710:The end result is a list containing
1043:: The Language" (2nd ed.): 418.
1001:"Why functional programming matters"
893:Do not confuse with the list method
563:Where reduce is Miranda's name for
13:
370:
14:
1110:
203:
377:high-level programming languages
188:) performs the same function as
42:high-level programming languages
894:
844:
840:
836:
1:
989:
560:append a b = reduce cons b a
66:procedure takes zero or more
7:
1089:Lisp (programming language)
806:"Some new text\n"
10:
1115:
794:"/some/file.txt"
580:
544:
1099:DOS on IBM PC compatibles
967:Goodbyeworld!>>text
826:
429:
391:. To append lists, as an
143:time and space complexity
978:
955:
903:
849:
770:
715:
660:
595:
512:
448:
414:Other languages use the
320:
223:
72:
944:
839:or the infix operators
649:
47:
1094:Programming constructs
1084:Functional programming
1056:Cite journal requires
1022:10.1093/comjnl/32.2.98
835:, use the list method
538:yields the solutions:
375:Following Lisp, other
211:can easily be defined
167:
132:;Output: (1 2 3 a b 6)
168:
29:is the operation for
442:features a built-in
157:
57:programming language
21:computer programming
960:Helloworld!>text
901:element to a list:
426:, list, or array.
1037:Steele, Guy L. Jr.
788:'>>'
180:procedure (called
163:
55:originates in the
847:to append lists.
436:logic programming
166:{\displaystyle n}
1106:
1069:
1065:
1059:
1054:
1052:
1044:
1032:
1030:
1024:. Archived from
1009:Computer Journal
1005:
985:
982:
970:
966:
963:
959:
940:
937:
934:
931:
928:
925:
922:
919:
916:
913:
910:
907:
896:
889:
886:
883:
880:
877:
874:
871:
868:
865:
862:
859:
856:
853:
846:
842:
838:
819:
816:
813:
810:
807:
804:
801:
798:
795:
792:
789:
786:
783:
780:
777:
774:
761:
758:
755:
752:
749:
746:
743:
740:
737:
734:
731:
728:
725:
722:
719:
706:
703:
700:
697:
694:
691:
688:
685:
682:
679:
676:
673:
670:
667:
664:
645:
638:
635:
632:
629:
626:
623:
620:
617:
614:
611:
608:
605:
602:
599:
534:
531:
528:
525:
522:
519:
516:
506:
503:
500:
497:
494:
491:
488:
485:
482:
479:
476:
473:
470:
467:
464:
461:
458:
455:
452:
445:
421:
417:
410:
402:
390:
387:have adopted an
366:
363:
360:
357:
354:
351:
348:
345:
342:
339:
336:
333:
330:
327:
324:
314:
311:
308:
305:
302:
299:
296:
293:
290:
287:
284:
281:
278:
275:
272:
269:
266:
263:
260:
257:
254:
251:
248:
245:
242:
239:
236:
233:
230:
227:
220:
210:
196:: it alters the
191:
183:
179:
172:
170:
169:
164:
140:
133:
130:
127:
124:
121:
118:
115:
112:
109:
106:
103:
100:
97:
94:
91:
88:
85:
82:
79:
76:
65:
54:
27:
1114:
1113:
1109:
1108:
1107:
1105:
1104:
1103:
1074:
1073:
1067:
1066:Description of
1057:
1055:
1046:
1045:
1028:
1003:
992:
987:
986:
983:
980:
973:
972:
968:
964:
961:
957:
947:
942:
941:
938:
935:
932:
929:
926:
923:
920:
917:
914:
911:
908:
905:
897:, which adds a
891:
890:
887:
884:
881:
878:
875:
872:
869:
866:
863:
860:
857:
854:
851:
829:
821:
820:
817:
814:
811:
808:
805:
802:
799:
796:
793:
790:
787:
784:
781:
778:
775:
772:
763:
762:
759:
756:
753:
750:
747:
744:
741:
738:
735:
732:
729:
726:
723:
720:
717:
708:
707:
704:
701:
698:
695:
692:
689:
686:
683:
680:
677:
674:
671:
668:
665:
662:
652:
643:
640:
639:
636:
633:
630:
627:
624:
621:
618:
615:
612:
609:
606:
603:
600:
597:
583:
578:
561:
547:
542:
536:
535:
532:
529:
526:
523:
520:
517:
514:
508:
507:
504:
501:
498:
495:
492:
489:
486:
483:
480:
477:
474:
471:
468:
465:
462:
459:
456:
453:
450:
443:
432:
419:
415:
408:
400:
388:
385:data structures
373:
371:Other languages
368:
367:
364:
361:
358:
355:
352:
349:
346:
343:
340:
337:
334:
331:
328:
325:
322:
316:
315:
312:
309:
306:
303:
300:
297:
294:
291:
288:
285:
282:
279:
276:
273:
270:
267:
264:
261:
258:
255:
252:
249:
246:
243:
240:
237:
234:
231:
228:
225:
216:
208:
206:
189:
181:
177:
158:
155:
154:
138:
135:
134:
131:
128:
125:
122:
119:
116:
113:
110:
107:
104:
101:
98:
95:
92:
89:
86:
83:
80:
77:
74:
63:
52:
50:
25:
17:
12:
11:
5:
1112:
1102:
1101:
1096:
1091:
1086:
1072:
1071:
1058:|journal=
1033:
1031:on 2007-04-13.
991:
988:
984:Goodbye world!
979:
956:
946:
943:
904:
850:
828:
825:
771:
716:
661:
651:
648:
596:
582:
579:
576:
559:
546:
543:
540:
513:
449:
431:
428:
379:which feature
372:
369:
321:
224:
205:
204:Implementation
202:
162:
153:for a list of
73:
68:(linked) lists
49:
46:
15:
9:
6:
4:
3:
2:
1111:
1100:
1097:
1095:
1092:
1090:
1087:
1085:
1082:
1081:
1079:
1063:
1050:
1042:
1038:
1034:
1027:
1023:
1019:
1016:(2): 98–107.
1015:
1011:
1010:
1002:
998:
994:
993:
977:
954:
952:
936:>>>
915:>>>
906:>>>
902:
900:
882:>>>
876:>>>
861:>>>
852:>>>
848:
834:
824:
769:
766:
714:
711:
659:
657:
647:
594:
592:
589:, this right-
588:
575:
574:For example,
572:
570:
566:
558:
556:
553:, this right-
552:
539:
511:
447:
441:
437:
427:
425:
412:
406:
398:
394:
386:
383:as primitive
382:
378:
319:
222:
219:
214:
201:
199:
195:
194:destructively
187:
174:
160:
152:
150:
144:
71:
69:
61:
58:
45:
43:
39:
35:
32:
31:concatenating
28:
22:
1049:cite journal
1026:the original
1013:
1007:
997:Hughes, John
981:Hello world!
974:
948:
898:
892:
830:
822:
767:
764:
712:
709:
653:
641:
584:
573:
562:
548:
537:
509:
433:
413:
381:linked lists
374:
317:
215:in terms of
207:
175:
148:
136:
51:
34:linked lists
24:
18:
1041:Common Lisp
213:recursively
1078:Categories
990:References
646:operator.
353:fold-right
137:Since the
1039:(1990). "
438:language
999:(1989).
971:cattext
393:operator
40:in some
742:unshift
727:unshift
587:Haskell
581:Haskell
551:Miranda
545:Miranda
397:Haskell
182:append!
1068:append
924:append
899:single
895:append
870:extend
837:extend
833:Python
827:Python
610:append
598:append
567:, and
518:append
484:append
469:append
451:append
444:append
440:Prolog
430:Prolog
424:string
389:append
335:lambda
329:append
326:define
295:append
238:lambda
232:append
229:define
209:Append
192:, but
190:append
186:Scheme
139:append
78:append
64:append
62:. The
53:Append
38:arrays
26:append
1029:(PDF)
1004:(PDF)
812:close
800:print
745:@list
730:@list
721:@list
690:@list
675:@list
666:@list
622:foldr
607:->
604:->
407:uses
405:OCaml
399:uses
313:)))))
262:null?
178:nconc
120:'
114:'
99:'
81:'
1062:help
965:echo
958:echo
951:Bash
945:Bash
843:and
815:$ fh
803:$ fh
782:$ fh
773:open
687:push
672:push
656:Perl
650:Perl
591:fold
569:cons
565:fold
555:fold
434:The
356:cons
277:cons
218:cons
176:The
145:are
60:Lisp
48:Lisp
1018:doi
949:In
831:In
654:In
585:In
549:In
533:,).
418:or
365:)))
310:ls2
304:ls1
301:cdr
286:ls1
283:car
271:ls2
265:ls1
247:ls2
244:ls1
198:cdr
184:in
36:or
19:In
1080::
1053::
1051:}}
1047:{{
1014:32
1012:.
1006:.
873:()
845:+=
797:);
779:my
718:my
663:my
644:++
637:xs
634:ys
616:ys
613:xs
601:::
515:?-
505:).
502:Zs
496:Ys
490:Xs
481::-
478:,)
475:Ys
472:(,
466:).
463:Ys
457:Ys
454:(,
420:++
411:.
403:,
401:++
395:,
256:if
147:O(
129:))
117:()
44:.
23:,
1070:.
1064:)
1060:(
1020::
969:;
962:;
939:l
933:)
930:3
927:(
921:.
918:l
912:=
909:l
888:+
885:l
879:l
867:.
864:l
858:=
855:l
841:+
818:;
809:;
791:,
785:,
776:(
760:;
757:3
754:,
751:2
748:,
739:;
736:1
733:,
724:;
705:;
702:3
699:,
696:2
693:,
684:;
681:1
678:,
669:;
631:)
628::
625:(
619:=
530:R
527:,
524:L
521:(
499:,
493:,
487:(
460:,
416:+
409:@
362:a
359:b
350:(
347:)
344:b
341:a
338:(
332:(
323:(
307:)
298:(
292:(
289:)
280:(
274:(
268:)
259:(
253:(
250:)
241:(
235:(
226:(
161:n
151:)
149:n
126:6
123:(
111:)
108:b
105:a
102:(
96:)
93:3
90:2
87:1
84:(
75:(
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.