javascript - Fill remaining length of array with falsy values using Ramda -


i have array of arrays looks this:

const difficulties = [   [true, true],   [true],   [true, true, true],   [true] ] 

what i’d perform transform on array using ramda, each of sub-arrays filled false, looking this:

[   [true, true, false],   [true, false, false],   [true, true, true],   [true, false, false] ] 

how go doing this?

with ramda use r.times , r.propor:

const difficulties = [    [true, true],    [true],    [true, true, true],    [true]  ];    let difficultiesfilled = r.map(e => r.times(i => r.propor(false, i, e), 3), difficulties);  console.log(difficultiesfilled);
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.24.1/ramda.min.js"></script>

if max length of arrays unknown do:

let maxlength = r.reduce(r.maxby(r.length), [], difficulties); 

and use instead of 3.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -