some more of eloquent datastructures
This commit is contained in:
parent
a759fef088
commit
ec72ed57b9
|
@ -1,42 +1,64 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Intro</title>
|
<title>Intro</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<div>Hei jeg heter</div>
|
<div>Hei jeg heter</div>
|
||||||
<div id="namediv">...her kommer et navn</div>
|
<div id="namediv">...her kommer et navn<br></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<div>Jeg bor i</div>
|
<div>Jeg bor i</div>
|
||||||
<div id="placediv">..her kommer et sted</div>
|
<div id="placediv">..her kommer et sted<br></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<div>Min favorittmat er</div>
|
<div>Min favorittmat er</div>
|
||||||
<div id="fooddiv">...her kommer en matrett</div>
|
<div id="fooddiv">...her kommer en matrett<br></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button onclick="setFields()">Klikk her for å sett inn verdier</button>
|
<button onclick="setFields()">Klikk her for å sett inn verdier</button>
|
||||||
|
Navn: <input type="text" onchange="setName(this.value)">
|
||||||
|
Sted: <input type="text" onchange="setPlace(this.value)">
|
||||||
|
Mat: <input type="text" onchange="setFood(this.value)">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let name;
|
|
||||||
|
// Model
|
||||||
|
let fistName;
|
||||||
let place;
|
let place;
|
||||||
let food;
|
let food;
|
||||||
|
// View
|
||||||
|
function setFields() {
|
||||||
|
document.getElementById("namediv").innerHTML = fistName;
|
||||||
|
document.getElementById("placediv").innerHTML = place;
|
||||||
|
document.getElementById("fooddiv").innerHTML = food;
|
||||||
|
|
||||||
function setFields(){
|
}
|
||||||
document.getElementById("namediv").innerHTML = "Geir";
|
// Controller
|
||||||
document.getElementById("placediv").innerHTML = "Kristiansand";
|
function setName(nameInput) {
|
||||||
document.getElementById("fooddiv").innerHTML = "Pizza";
|
firstName = nameInput;
|
||||||
|
setFields();
|
||||||
|
}
|
||||||
|
function setPlace(placeInput) {
|
||||||
|
place = placeInput;
|
||||||
|
setFields();
|
||||||
|
}
|
||||||
|
function setFood(foodInput) {
|
||||||
|
food = foodInput;
|
||||||
|
setFields();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.group{
|
.group {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
padding: 1px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -113,4 +113,22 @@ function phi(table) {
|
||||||
(table[1] + table[3]) *
|
(table[1] + table[3]) *
|
||||||
(table[0] + table[2]));
|
(table[0] + table[2]));
|
||||||
};
|
};
|
||||||
// console.log(phi([76, 9, 4, 1]));
|
function journalEvents(journal){
|
||||||
|
let events = [];
|
||||||
|
for (let entry of journal){
|
||||||
|
for (let event of entry.events){
|
||||||
|
if (!events.includes(event)){
|
||||||
|
events.push(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
console.log(journalEvents(JOURNAL));
|
||||||
|
|
||||||
|
for (let event of journalEvents(JOURNAL)){
|
||||||
|
let correlation = phi(tableFor(event, JOURNAL));
|
||||||
|
if (correlation > 0.1 || correlation < -0.1){
|
||||||
|
console.log(event + ":", correlation)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue