1// Slight modification of public domain Wizzcake+ interpreter by esolang user RainbowDash 2function wizzcakep(inputPrgm){ 3 // Usage 4 let words = inputPrgm.toUpperCase().split(" "); 5 let cells = [0]; // Initalize cells 6 let stack = []; 7 let cursorPos = 0 // Set pointer 8 let i = 0; 9 let output=""; 10 while (i < words.length) { 11 let word = words[i]; 12 if(word != "[" && word != "]" && word != ","){ 13 i++ 14 let hash = 0; 15 for (let j = 0; j < word.length; j++) { 16 hash = (hash << 5) - hash + word.charCodeAt(j); 17 hash |= 0; // Convert to 32-bit integer 18 } 19 let seed = Math.abs(hash) / Math.pow(2, 31); // Unique number generated for every word 20 if (word.length === 1) { 21 seed = (word.charCodeAt(0) * 2654435761) % Math.pow(2, 31); 22 } 23 var x = Math.sin(seed) * 10000; 24 var outputSeed = x - Math.floor(x); 25 var amountOfLoops = Math.round(outputSeed * 5)+1; 26 for (let i = 0; i < amountOfLoops; i++) { 27 outputSeed = seed; 28 x = Math.sin(outputSeed) * 10000; 29 outputSeed = x - Math.floor(x); 30 let instruction = Math.round(outputSeed * 9)+1; 31 switch(instruction) { 32 case 1: // Move pointer right 33 cursorPos += 1 34 break; 35 case 2: // Move pointer left 36 cursorPos -= 1 37 break; 38 case 3: // Increment pointer cell 39 cells[cursorPos] = (cells[cursorPos] || 0) + 1; 40 break; 41 case 4: // Decrement pointer cell 42 cells[cursorPos] = Math.max(((cells[cursorPos] || 0) - 1),0); 43 break; 44 case 5: // Print out pointer cell 45 output+=(cells[cursorPos] ?? 0)+'\n'; 46 break; 47 case 6: // Print out pointer cell ASCII 48 output+=(String.fromCharCode(cells[cursorPos] ?? 0))+'\n'; 49 break; 50 case 7: // Pop stack 51 if (stack.length > 0){ 52 output+=(stack.join(" "))+'\n'; 53 stack = []; 54 } 55 break; 56 case 8: // Push cell to stack 57 stack.push(cells[cursorPos]); 58 cells[cursorPos] = 0; 59 break; 60 case 9: // Clear cell 61 cells[cursorPos] = 0; 62 break; 63 case 10: //Pop stack ASCII 64 if (stack.length > 0){ 65 stack.forEach(number => { 66 output+=String.fromCharCode(number)+'\n'; 67 }); 68 stack = []; 69 } 70 break; 71 } 72 seed++; 73 } 74 } else { 75 if(word == ","){ 76 var input = prompt(""); 77 var inputASSCI = input.split(''); 78 for (let h = 0; h < inputASSCI.length; h++) { 79 cells[cursorPos] = (inputASSCI[h].charCodeAt(0)); 80 cursorPos += 1 81 } 82 cursorPos -= 1 83 i++ 84 } else if (word == "]") { 85 if ((cells[cursorPos] || 0) <= 0) { 86 i++; // Move to the next instruction 87 } else { 88 let loopDepth = 1; 89 while (loopDepth > 0) { 90 i--; // Move back to find the matching [ 91 if (words[i] === "]") { 92 loopDepth++; 93 } else if (words[i] === "[") { 94 loopDepth--; 95 } 96 } 97 } 98 } else { i++ } 99 } 100 } 101}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.