Created
          August 8, 2014 21:48 
        
      - 
      
- 
        Save Chandler/25ff9cce03d1f5d54dc2 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | case class WriteEvent(name: String, records: List[Int]) | |
| case class SingleRecord(name: String, value: Int) | |
| val events = List( | |
| WriteEvent("follow", List(1,2,3)), | |
| WriteEvent("block", List(2,3,4)), | |
| WriteEvent("follow", List(5,6,7)) | |
| ) | |
| def convert(event: WriteEvent): List[SingleRecord] = { | |
| event.records.map { value => | |
| SingleRecord(event.name, value) | |
| } | |
| } | |
| events.flatMap { convert(_) } | |
| //res9: List[SingleRecord] = List(SingleRecord(follow,1), SingleRecord(follow,2), SingleRecord(follow,3), SingleRecord(block,2), SingleRecord(block,3), SingleRecord(block,4), SingleRecord(follow,5), SingleRecord(follow,6), SingleRecord(follow,7)) | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment