13 lines
		
	
	
		
			325 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
		
		
			
		
	
	
			13 lines
		
	
	
		
			325 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| 
								 | 
							
								(* Binary tree with leaves carrying an integer. *)
							 | 
						|||
| 
								 | 
							
								type tree = Leaf of int | Node of tree * tree
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								let rec exists_leaf test tree =
							 | 
						|||
| 
								 | 
							
								  match tree with
							 | 
						|||
| 
								 | 
							
								  | Leaf v -> test v
							 | 
						|||
| 
								 | 
							
								  | Node (left, right) ->
							 | 
						|||
| 
								 | 
							
								      exists_leaf test left
							 | 
						|||
| 
								 | 
							
								      || exists_leaf test right
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								let has_even_leaf tree =
							 | 
						|||
| 
								 | 
							
								  exists_leaf (fun n -> n mod 2 = 0) tree
							 |