Skip to content

Instantly share code, notes, and snippets.

@raphaelschaad
Created June 22, 2019 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raphaelschaad/ea0faae04deaea042906831381729b97 to your computer and use it in GitHub Desktop.
Save raphaelschaad/ea0faae04deaea042906831381729b97 to your computer and use it in GitHub Desktop.
Takes two arrays of numbers and outputs a third one with all numbers that occur in both. (script for Catherine's data analysis)
'use strict';
const fs = require('fs');
const col1 = [190, 281, 1020, 32, 1007, 1090, 812, 123, 1298, 1006, 927, 1092, 946, 1426, 1003, 1226, 164, 671, 382, 285, 1628, 1037, 535, 295, 574, 1005, 401, 862, 1171, 1068, 544, 1066, 1172, 511, 754, 658, 810, 234, 885, 124, 424, 115, 928, 545, 368, 582, 246, 779, 1022, 853, 40, 821, 1170, 740, 1023, 880, 531, 304, 879, 1240, 477, 683, 284, 921, 1173, 999, 280, 618, 1000, 882, 207, 156, 1393, 1341, 1340, 947, 527, 1347, 1004, 362];
const col2 = [114, 281, 848, 1453, 1108, 1049, 1400, 1447, 1191, 1177, 1186, 1054, 521, 370, 679, 55, 30, 1440, 1488, 451, 193, 619, 73, 101, 903, 1481, 1130, 1438, 104, 708, 1298, 480, 235, 1228, 94, 1039, 518, 1850, 942, 1131, 951, 218, 430, 1225, 426, 1712, 889, 254, 1139, 468, 226, 782, 1363, 237, 1218, 694, 1739, 1031, 1426, 1193, 500, 488, 790, 1487, 1107, 1252, 1220, 612, 490, 671, 382, 1856, 285, 1046, 1863, 1344, 219, 1123, 61, 1124, 336, 483, 869, 923, 1435, 1037, 535, 739, 918, 1102, 295, 722, 255, 558, 904, 1129, 1653, 839, 1588, 102, 204, 574, 390, 78, 504, 403, 170, 1114, 912, 1048, 862, 1181, 412, 855, 179, 457, 1034, 1178, 651, 551, 1510, 539, 63, 802, 677, 227, 1489, 1043, 774, 1231, 318, 608, 776, 907, 307, 700, 909, 893, 685, 1823, 1482, 822, 1227, 935, 649, 1432, 454, 963, 1587, 233, 678, 902, 672, 520, 1047, 658, 150, 404, 673, 72, 729, 1128, 1116, 37, 965, 439, 701, 124, 846, 1188, 1018, 175, 1045, 906, 442, 1117, 313, 1111, 1038, 493, 436, 424, 1701, 1041, 515, 936, 533, 696, 900, 1155, 1234, 368, 68, 1271, 1113, 1221, 557, 1120, 582, 316, 391, 461, 961, 911, 147, 1022, 1148, 215, 684, 417, 652, 703, 1192, 148, 1010, 821, 740, 1494, 637, 1667, 1109, 531, 174, 1443, 611, 1179, 971, 914, 1343, 1035, 840, 506, 1134, 642, 380, 477, 1360, 683, 1297, 277, 662, 554, 471, 647, 1512, 448, 950, 409, 1433, 446, 420, 921, 1224, 284, 596, 1055, 1594, 860, 730, 1393, 1442, 1230, 905, 1239, 890, 349, 1233, 913, 1176, 1274, 236, 719, 1471, 620, 1335, 799, 1015, 1042, 1040, 1472, 360, 346, 919, 716, 990, 280, 775, 1364, 484, 806, 1061, 1115, 610, 553, 1345, 548, 1600, 1282, 445, 1485, 348, 510, 1184, 470, 807, 1486, 428, 1341, 796, 901, 633, 710, 319, 329, 100, 823, 310, 669, 528, 1044, 1340, 1016, 630, 1247, 1036, 1189, 747, 540, 969, 375, 76, 372, 1187, 626, 689, 883, 99, 1347, 594, 275, 1235, 286, 861, 120, 908, 541, 362, 334, 629, 666];
const col3 = col1.map(e => col2.includes(e) ? e : undefined).filter(e => e);
console.log('Writing ' + col3.length + ' matches to file.');
fs.writeFileSync('col3.js', col3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment