Fandom

Distributed Interactive Functional Fiction Programming

Join lists

13pages on
this wiki
Add New Page
Talk0 Share

Main_Page/Snack Code/List Recursion/Join lists

Haskell:

module Join where

-- <++> joins two lists
(<++>):: [a] -> [a] -> [a]
[] <++>  xs = xs
(y:ys) <++> xs = y : (ys <++> xs) 

-- <++> example 
testJoin = [1,2,3] <++> [4,5]
-- returns [1,2,3,4,5]

Scheme:

; <++> joins lists
(define (<++> ys xs) 
  (cond ((null? ys) xs)
	(else (cons (car ys) (<++> (cdr ys) xs)))
	))

; <++> example
(define test<++> (<++> '(1 2 3) '(4 5)))
; returns (1 2 3 4 5)

--Dokondr 13:51, 28 February 2006 (UTC)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.