<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with printarray() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=printarray%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:15:27 +0000</pubDate>
         <description>Tagged with printarray() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedprintarray%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>List of available fonts is truncated (PFont.list())</title>
      <link>https://forum.processing.org/two/discussion/25772/list-of-available-fonts-is-truncated-pfont-list</link>
      <pubDate>Sun, 31 Dec 2017 20:49:00 +0000</pubDate>
      <dc:creator>fabricated_bison</dc:creator>
      <guid isPermaLink="false">25772@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone, first post here. I'm reading through Reas and Fry's instruction book on processing and I've come to chapter 12 dealing with typography. There's a function they use to print to the console a list of available fonts:
<code>printArray(PFont.list());</code>
The list that I get however begins at number 79 and omits all entries before that. This differs from the list of the authors' and prevents me from seeing all available fonts. There are other ways to see a list of installed fonts, but I would like to correct this in case the underlying issue becomes problematic for a future sketch.</p>
]]></description>
   </item>
   <item>
      <title>Primitive Neural Network array problem</title>
      <link>https://forum.processing.org/two/discussion/19873/primitive-neural-network-array-problem</link>
      <pubDate>Wed, 21 Dec 2016 18:51:28 +0000</pubDate>
      <dc:creator>Trilobyte</dc:creator>
      <guid isPermaLink="false">19873@/two/discussions</guid>
      <description><![CDATA[<p>Hello all. I am currently building a primitive neural network that reads an input of five letter English words and uses the data it gathers from them to produce words that could be English. I am having a problem where, in trying to  assign percentage values to a 2D array, the program freezes and times out. Any input would be appreciated. Problem occurs on line 170
. Thanks.</p>

<pre><code>String input = "aa";
String output = "aa";
//===============================
final int CRETVAL = 1000;
int ax = 400;
int by = 20;
int cx = CRETVAL;
int dy = 20;
int size = 22;
int spacing = 25;
//===============================
int numLetters = 26;
int numLetPerWord = 5;
//===============================
int baseval =0;
//===============================
//String all[] = {""};
String testing[] = new String[8560];
int testLength;
//===============================
int iter = 0;
int[][] Grid = new int[27][27];
float[][] percentGrid = new float[27][27];
float[] percents = new float[26];
//===============================
String interim = "";
char plholder1 = 'a';
char plholder2 = 'a';
int arx, ary;
//===============================

void setup() {
  frameRate(240);
  background(0);
  size(700, 700);
  strokeWeight(4);
  stroke(255);
  line(width/2, 0, width/2, height);
  String all5Letters[]  = loadStrings("5letterwords.txt");
  //String Test[]  = loadStrings("5lettertest.txt");
  arrayCopy(all5Letters, testing);
  // arrayCopy(Test, testing);
  //println("there are " + all5Letters.length + " lines");
  //println("there are " + Test.length + " lines in the test. They are as follows:");
  //println(Test);
  testLength= all5Letters.length;
  fill(255, 255, 0);
  stroke(0, 200);
  println("Length = " +testLength);
  for (int i = 0; i&lt;27; i++) {
    for (int j = 0; j&lt;27; j++) {
      Grid[i][j] = baseval;
      //printArray(Grid[i][j]);
      //baseval ++;
    }
  }

  initGridVal();


  percentGrid = calculatePercents(Grid);
} // end setup


//&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
void draw() {
  textSize(50);
  background(0);
  strokeWeight(4);
  stroke(255);
  line(width/2, 0, width/2, height);

  input = testing[iter];
  output = testing[iter];
  pushMatrix();
  textAlign(LEFT);
  text(input, 100, 60);
  textAlign(RIGHT);
  text(output, width-100, 60);
  popMatrix();
  if ( iter&lt;testLength-1) {
    iter++;
  }
}
//&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;

//|GRID_INITIALIZATION|GRID_INITIALIZATION|GRID_INITIALIZATION|GRID_INITIALIZATION|
public void initGridVal() {
  for (int i = 0; i&lt;testLength; i++) {
    interim = testing[i];
    for (int j = 0; j&lt;numLetPerWord-1; j++) {
      plholder1 =  interim.charAt(j);
      plholder2 =  interim.charAt(j+1);
      arx = xArrayVal(plholder1);
      ary = yArrayVal(plholder2);
      Grid[arx][ary] ++;
    }
  }
  for (int i = 0; i&lt;26; i++) {
    for (int j = 0; j&lt;26; j++) {
      printArray(Grid[i][j]);
      //baseval ++;
    }
  }
}
//|GRID_INITIALIZATION|GRID_INITIALIZATION|GRID_INITIALIZATION|GRID_INITIALIZATION|

//&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
public int xArrayVal(char in1) { //first letter
  //  int retX = Character.getNumericValue(in1)-36;
  int retX = (int)in1-97;
  return retX;
}

public int yArrayVal(char in2) { // second letter
  // int retY = Character.getNumericValue(in2)-36;
  int retY = (int)in2-97;
  return retY;
}
//&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;

/*
                                                i

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 1                                                                         
 2                                                                          
 3                                                                          
 4                                                                          
 5                                                                            
 6
 7
 8
 9
 10
 11
 12
 j     13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 */

//% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
public float[][]calculatePercents(int[][] importGrid) {
  float[][] ArrPercents = new float[27][27];
  int[] totalPerRow = new int[27]; 

  for (int k = 0; k&lt;27; k++) {    
    for (int l = 0; l&lt;27; l++) {
      totalPerRow[k] += importGrid[k][l];
    }
  }
  printArray(totalPerRow);

  for (int I = 0; I&lt;27; I++) {    
    for (int J = 0; J&lt;27; J++) {

      ArrPercents[I][J] = (Grid[I][J]) /(totalPerRow[I]);
    }
  }
  print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
  printArray(ArrPercents);

  return ArrPercents;
}
//% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 


//+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+
public String returnWeightedLetters(float[] percentArray) {
  String weightedLetters = "";
  int percent = 0;
  char added = 'a';
  //for(int i = 0; i&lt; percentArray.length; i++){
  for (int i = 0; i&lt; 26; i++) {
    percent = int(100*percentArray[i]);
    for (int j = 0; j&lt;percent; j++) {
      weightedLetters = weightedLetters + added;
    }
    added++;
  }

  return weightedLetters;
}


public String chooseNextLetter(String weightedInputLetters) {
  String returnLetter= "";
  int x = int(random(0, weightedInputLetters.length()));
  returnLetter = returnLetter + weightedInputLetters.charAt(x);
  return returnLetter;
}
//+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+C+


public String splice(String a, String b) {
  String result = "";

  return result;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to add a string of text to a String array on buttonClick?</title>
      <link>https://forum.processing.org/two/discussion/18728/how-to-add-a-string-of-text-to-a-string-array-on-buttonclick</link>
      <pubDate>Wed, 26 Oct 2016 15:20:50 +0000</pubDate>
      <dc:creator>Mitch_</dc:creator>
      <guid isPermaLink="false">18728@/two/discussions</guid>
      <description><![CDATA[<p>So basically i want my sketch to remember what the last ten buttons are that have been clicked. I will see later on if i can make it so that it only prints the last 10 items added to the array but first i need to know how to add a string of text to a String array on buttonClick.</p>

<p>If i run the following sketch and press ENTER i get null in the console.</p>

<pre><code>String[] buttons; 
String displayButtons;

void setup(){  
  buttons = new String[3]; 
  displayButtons = join(buttons, " : ");
}

void draw(){
}

void keyPressed() {
  if ((key=='1')) { 
   buttons[0] = "You pressed button one";
  }

  if ((key=='2')) { 
    buttons[1] = "You pressed button two";
  }

  if ((key==ENTER)) { 
    printArray(displayButtons);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>array prints weird stuff</title>
      <link>https://forum.processing.org/two/discussion/11524/array-prints-weird-stuff</link>
      <pubDate>Wed, 01 Jul 2015 03:22:25 +0000</pubDate>
      <dc:creator>plux</dc:creator>
      <guid isPermaLink="false">11524@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I have this simple code that does not work in my sketch. I have a function which creates and prints an array of 3 elements..but I don't understand why it will print weird stuff instead of the values stored inside of it</p>

<pre><code>void makeChord(int tuning){

    float[] chord = new float[3];
    chord[0] = 10;
    chord[1] = 11;
    chord[2] = 12;
    println("CHORD "+chord);
}
</code></pre>

<p>will print something like</p>

<pre><code>CHORD [F@704c6d5c
CHORD [F@299fec9d
CHORD [F@42674cc4
CHORD [F@be0f9eb
CHORD [F@436c8512
</code></pre>

<p>the function gets callend inside another function that's inside the draw. if I put this code in the draw, it will throw the same result. In a new sketch instead it will work fine. no errors in the console</p>

<p>same result also if I do this way</p>

<pre><code>float[] chord = {10,10,10};
println("CHORD "+chord);
</code></pre>

<p>note that I have other arrays in the same sketch and they all work fine)
thanks</p>
]]></description>
   </item>
   <item>
      <title>File Name reader problem</title>
      <link>https://forum.processing.org/two/discussion/10620/file-name-reader-problem</link>
      <pubDate>Sun, 03 May 2015 10:34:48 +0000</pubDate>
      <dc:creator>Skyfreak12345</dc:creator>
      <guid isPermaLink="false">10620@/two/discussions</guid>
      <description><![CDATA[<p>hi,</p>

<p>I am trying to make a data store and I want to ask the user the question if he wants to use an existing file or he wants to create a new one, for that I have to read the filenames and print him the existing ones, and I don't know how to do that, I already had a look at another contribution but that didn't help me (I am not the best programmer)</p>
]]></description>
   </item>
   <item>
      <title>Using printArray()</title>
      <link>https://forum.processing.org/two/discussion/6211/using-printarray</link>
      <pubDate>Tue, 08 Jul 2014 12:05:49 +0000</pubDate>
      <dc:creator>rickygraham</dc:creator>
      <guid isPermaLink="false">6211@/two/discussions</guid>
      <description><![CDATA[<p>I'd like to print the contents of an array. I found printArray(), however, it doesn't seem to work (function does not exist)? I'm using Processing 2.0.2.</p>

<pre><code>Sample Code:

float[] f = { 0.3, 0.4, 0.5 };
printArray(f);

// The above code prints:
// [0] 0.3
// [1] 0.4
// [2] 0.5
</code></pre>

<p><a href="https://www.processing.org/reference/printArray_.html" target="_blank" rel="nofollow">https://www.processing.org/reference/printArray_.html</a></p>

<p>Thanks very much in advance.</p>
]]></description>
   </item>
   </channel>
</rss>