I'm personally attempting to learn the little man computer.
I found a problem:
Write an LMC (Little Man Computer) program to do the following task.
if (value == 0) {
some_statements;
}
next_statement;
My current answer:
00 901 IN (value)
01 399 STORE
02 808 TEST
03 901 IN (value)
04 808 TEST
05 000 STOP
I don't believe this is right... can anyone please assist me? any instructional information would be appreciated or direction. Thank you.
All the computer does is follow a stream of codes, like add, subtract, store, etc...
One of the codes allows you to jump past other code. This is how the computer handles conditionals at the most basic level. The BRZ code will branch to a specified line of code if your accumulator is set to 0.
10 Input to accumulater
20 BRZ 60 < go to line 60 if accumulator is 0
30 do something //skip me
40 do something //skip me
50 HALT
60 do something else
70 do something else
80 BRZ 30
If the accumulator wasn't 0, it would just follow along and do lines 30 and 40 and then terminate at line 50.
Related
I am building a copybook request for IBM MQ and in the request I have to send an arraylist of elements having values. I am getting the exception
too few values for 'IO-ARRAY' of segment COMMAREA at position 0 (com.mulesoft.flatfile.lexical.WriteException).
I am using mule 3.8 and configuring the output of Data transformer as 'Copybook'. PFB my configurations,
Data Transform: https://i.stack.imgur.com/2kO8c.png
Here is the copybook file I am using,
01 COMMAREA.
05 MQ-CNTL.
10 MQ-MSGID PIC X(08).
05 INPUT-OUTPUT.
10 ID1 PIC X(04).
10 ID2 PIC X(08).
10 IO-ARRAY OCCURS 99 INDEXED BY IO-ARRAY.
15 ELEMENT1 PIC X(03).
15 ELEMENT2 PIC X(03).
15 ELEMENT3 PIC X(01).
15 ELEMENT4 PIC X(01).
15 ELEMENT5 PIC X(02).
Can you please help resolve this?
As per your Dataweave Configuration, you Just Write only one time in an array of IO-ARRAY but based on your copybook it is expecting 99 times(occurs 99).
I hope you got the point
My understanding is that this line:
10 IO-ARRAY OCCURS 99 INDEXED BY IO-ARRAY.
indicates that there is a dependency on the IO-ARRAY field. For reference look into the below code snippet.
01 WS-TABLE.
05 WS-A OCCURS 3 TIMES INDEXED BY I.
10 WS-B PIC A(2).
10 WS-C OCCURS 2 TIMES INDEXED BY J.
15 WS-D PIC X(3).
I'm fairly new to this, and have done a lot of searching, but I'm not even 100% sure what exactly to search for, except I know I need to use Transform.
I basically need this:
Column A Column B
Total 184
Half 20
Some 25
None 30
Total 52
Half 25
Some 16
None 86
To become:
Total Half Some None
184 20 25 30
52 25 16 86
Any help would be amazing, it's the last part of a query, then it's done.
Thanks :)
The answer ended up being something like this. Don't do it with the Query Wizard, it won't work out very well. This is Access 2010.
TRANSFORM First(Table.ColumnB) AS FirstOfColumnB
SELECT Table.Columns
FROM Table
GROUP BY Table.Columns
PIVOT Table.ColumnA;
If you look at the original Wordnet search and select "Display options: Show Lexical File Info", you'll see an extremely useful classification of words called lexical file. Eg for "filling" we have:
<noun.substance>S: (n) filling, fill (any material that fills a space or container)
<noun.process>S: (n) filling (flow into something (as a container))
<noun.food>S: (n) filling (a food mixture used to fill pastry or sandwiches etc.)
<noun.artifact>S: (n) woof, weft, filling, pick (the yarn woven across the warp yarn in weaving)
<noun.artifact>S: (n) filling ((dentistry) a dental appliance consisting of ...)
<noun.act>S: (n) filling (the act of filling something)
The first thing in brackets is the "lexical file". Unfortunately I have not been able to find a SPARQL endpoint that provides this info
The latest RDF translation of Wordnet 3.0 points to two things:
Talis SPARQL endpoint. Use eg this query to check there's no such info:
DESCRIBE <http://purl.org/vocabularies/princeton/wn30/synset-chair-noun-1>
W3C's mapping description. Appendix D "Conversion details" describes something useful: wn:classifiedByTopic.
But it's not the same as lexical file, and is quite incomplete. Eg "chair" has nothing, while one of the senses of "completion" is in the topic "American Football"
DESCRIBE <http://purl.org/vocabularies/princeton/wn30/synset-completion-noun-1> ->
<j.1:classifiedByTopic rdf:resource="http://purl.org/vocabularies/princeton/wn30/synset-American_football-noun-1"/>
The question: is there a public Wordnet query API, or a database, that provides the lexical file information?
Using the Python NLTK interface:
from nltk.corpus import wordnet as wn
for synset in wn.synsets('can'):
print synset.lexname
I don't think you can find it in the RDF/OWL Representation of WordNet. It's in the WordNet distribution though: dict/lexnames. Here is the content of the file as of WordNet 3.0:
00 adj.all 3
01 adj.pert 3
02 adv.all 4
03 noun.Tops 1
04 noun.act 1
05 noun.animal 1
06 noun.artifact 1
07 noun.attribute 1
08 noun.body 1
09 noun.cognition 1
10 noun.communication 1
11 noun.event 1
12 noun.feeling 1
13 noun.food 1
14 noun.group 1
15 noun.location 1
16 noun.motive 1
17 noun.object 1
18 noun.person 1
19 noun.phenomenon 1
20 noun.plant 1
21 noun.possession 1
22 noun.process 1
23 noun.quantity 1
24 noun.relation 1
25 noun.shape 1
26 noun.state 1
27 noun.substance 1
28 noun.time 1
29 verb.body 2
30 verb.change 2
31 verb.cognition 2
32 verb.communication 2
33 verb.competition 2
34 verb.consumption 2
35 verb.contact 2
36 verb.creation 2
37 verb.emotion 2
38 verb.motion 2
39 verb.perception 2
40 verb.possession 2
41 verb.social 2
42 verb.stative 2
43 verb.weather 2
44 adj.ppl 3
For each entry of dict/data.*, the second number is the lexical file info. For example, this filling entry contains the number 13, which is noun.food.
07883031 13 n 01 filling 0 002 # 07882497 n 0000 ~ 07883156 n 0000 | a food mixture used to fill pastry or sandwiches etc.
It can be done through MIT JWI (MIT Java Wordnet Interface) a Java API to query Wordnet. There's a topic in this link showing how to implement a java class to access lexicographic
This is what worked for me,
Synset[] synsets = database.getSynsets(wordStr);
ReferenceSynset referenceSynset = (ReferenceSynset) synsets[i];
int lexicalCode =referenceSynset.getLexicalFileNumber();
Then use above table to deduce "lexnames" e.g. noun.time
If you're on Windows, chances are it is in your appdata, in the local directory. To get there, you will want to open your file browser, go to the top, and type in %appdata%
Next click on roaming, and then find the nltk_data directory. In there, you will have your corpora file. The full path is something like:
C:\Users\yourname\AppData\Roaming\nltk_data\corpora
and lexnames will present under
C:\Users\yourname\AppData\Roaming\nltk_data\corpora\wordnet.
I am reading a variable length input file and wanting to create an output buffer (indexed table) that will not utilize a character by character move.
For example: my first input record is 79 characters, I can then move this to my group level of the table. My second input record is 101 characters -- how can I take these 101 characters and place them in my table beginning at position 80 for a length of 101 ? And the next input record beginning at position 180.....etc. We currently Perform Varying 1 by 1 but this is incredibly CPU intensive compared to a block move to a beginning address.
We do this millions of times a day and a solution would be quite useful.
Use reference modification with the length from your record. Consider:
01 Record
05 Rec-LL Pic S9(4) Binary.
05 Rec-Data Pic X(32767).
01 Tgt-Area Pic X(10000000).
01 Curr-Ptr Pic S9(8) Binary.
Once you read your record, you can move based on the length like so:
Move 1 to Curr-Ptr
Perform Get-Next-Record
Perform until no-more-data
Move Rec-Data (1:Rec-LL) to Tgt-Area (curr-ptr:rec-LL)
Compute Curr-Ptr = Curr-Ptr + Rec-LL
Perform Get-Next-Record
End-Perform
Or the old fashioned ( we are talking COBOL here so old fashioned = Jurassic) way:-
01 Record.
05 REC-LL PIC S9(4) Binary.
05 REC-DATA.
10 REC-BYTES PIC X OCCURS 32767 times depending on REC-LL.
01 TARGET-AREA.
05 TARGET-HEADER PIC X(79).
05 TARGET-REC PIC X(101) OCCURS 50 TIMES.
01 TGT-INDEX PIC S9(8) BINARY VALUE 1.
* Length calculation happens by magic!
Perform Read-Record.
move REC-DATA TO TARGET-HEADER.
perform until no-more-data
Perform Read-Record
move REC-DATA to TARGET-RED(TGT-INDEX)
add +1 to TGT-INDEX
end-perform
Or if records really vary between 1 and 101 bytes:
01 Record.
05 REC-LL PIC S9(4) Binary.
05 REC-DATA.
10 REC-BYTES PIC X OCCURS 32767 times depending on REC-LL.
01 TARGET-AREA.
05 TGT-LL PIC s9(8) BINARY.
05 TGT-REC.
10 TGX-BYTE OCCURS 3175 depending on TGT-LL.
05 TGT-EXTRA PIC X(101).
Perform Read-Record.
Move +0 to tgt-LL.
perform until no-more-data
MOVE REC-DATE to TGT-EXTRA
ADD REC-LL TO TGT-LL
Perform Read-Record
add +1 to TGT-INDEX
end-perform
Take a look at the STRING INTO verb, in particular the WITH POINTER clause. Don't forget the ON OVERFLOW imperative when stringing things together like this.
For details, grab a copy of Gary Cutler's OpenCOBOL Programmer's Guide.
http://opencobol.add1tocobol.com/OpenCOBOL%20Programmers%20Guide.pdf
This is a world class COBOL manual, and it's an open and free document (GNU FDL).
I have to declare n = 01. But whenever I try it's getting changed to 1.
What should I try?
If this is just for display purposes then I would use the .ToString("0#"), unless you really need to do calculations based on two significant figures.
For index As Integer = 1 To 100
Console.WriteLine(index.ToString("0#"))
Next
Gives you
01
02
.
.
100