sicp-ex-4.66



<< Previous exercise (4.65) | Index | Next exercise (4.67) >>


meteorgan

  
  
  
 If Ben want to get to sum of salary of wheels, he can you this query: 
 (and (wheel ?who) (salary ?who ?amount)) 
 and gets: 
 (and (wheel (Warbucks Oliver)) (salary (Warbucks Oliver) 150000)) 
 (and (wheel (Warbucks Oliver)) (salary (Warbucks Oliver) 150000)) 
 (and (wheel (Bitdiddle Ben)) (salary (Bitdiddle Ben) 60000)) 
 (and (wheel (Warbucks Oliver)) (salary (Warbucks Oliver) 150000)) 
 (and (wheel (Warbucks Oliver)) (salary (Warbucks Oliver) 150000)) 
 you can see that Warbucks Oliver's salary occurs four times, so in the sum, Warbucks Oliver's salary will be duplicated. Ben can use an unique function to filter the duplication in the amount. 
  

the filtering subject should be keyed on the staff name rather than the amount itself.