Created
September 14, 2016 12:11
-
-
Save SuperManEver/361cb12c99388e82312c0a7c634f789b to your computer and use it in GitHub Desktop.
This file contains 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
var articles = [ | |
{ | |
title: 'Everything Sucks', | |
url: 'http://do.wn/sucks.html', | |
author: { | |
name: 'Debbie Downer', | |
email: 'debbie@do.wn' | |
} | |
}, | |
{ | |
title: 'If You Please', | |
url: 'http://www.geocities.com/milq', | |
author: { | |
name: 'Caspar Milquetoast', | |
email: 'hello@me.com' | |
} | |
} | |
]; | |
var defineElem = function (obj) { | |
return [ | |
(function (obj) { | |
return (R.compose(R.prop('name'), R.prop('author')))(obj) | |
})(obj) | |
, | |
(function (obj) { | |
return (R.prop('title'))(obj); | |
})(obj) | |
]; | |
}; | |
var titleAndName = R.reduce((acc, obj) => { | |
return acc.concat([ defineElem(obj) ]); | |
}, []); | |
titleAndName(articles); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As you can see I use tennent's correspondence principle in order to delay actual evaluation of how components will be formed. I don't know is it necessary or not, but this is how I did this