Instructions:
What is Handly?
Handly is an application for smartphone and computer that allow translation the sign language in real time with the cam of the device.
The application allow also to have french dictionnay - sign language of all alphabetical letters, french words and also current expression.
The application aggregate all the needs for communicate with an hard of hearing
How to use it?
To translate the person who talk with the sign language : Go to the page "live sign's language translator". Then record the personne who need to put his hands at the center of the camera.
Each words, letter or expression will in real time.
To knows the translation of a letter,words or expression : Go to the page "Sign's dictionnay". Enter your search in the seach's input. The sign will be display and you need only to reproduce it.


This example demonstrates how Smooks together with Smooks for Mule can be used to split, enrich,
transform and route huge messages (GB size messages).
Because of the complexity of this example, a detailed explanation of how it works is provided within this page.
The Mule and Smooks configuration files are also thoroughly documented.
In many uses cases, messages can contain data that is of interest to multiple parties. Each party can have different requirements, for instance a different data format or a different delivery method. A party could also require information which is related to the message but isn't in the message itself. It becomes even more complex when the source message is a huge (GB size) data stream. It the responsibility of the ESB to take care of these integration requirements.
Extracting, enriching and distributing information from a message to multiple parties is not a trivial process. The information must first be extracted by splitting the huge message in it's parts. Then some outside data source, for instance a database or some services, must be queried for the information to enrich the source information. The new set of information must then be reassembled in the required format for every party.
Smooks together with Smooks for Mule enables Mule to solve these issues in a powerful, performant and declaritive manner. Mule provides the transport layer for streaming in the huge message and to dispatch the splitted and enriched messages back to it's consumers. Smooks provides the capabilities to split, enrich and transform/generate the split messages, as well as trigger the routing of the split messages to their target endpoint. Smooks for Mule glues the two together.
This example is based on the use case that the information of a set of products needs to be sent to multiple parties. The ESB receives the information from an EDI file stored on the file system. Each product contains it's base information (product id, name, brand, price etc), as well as a list of parts and a list of technical specifications.
The following lists the consuming parties and there requirements:
The main challenges are:
Make sure you have set the MULE_HOME environment variable
and that you have installed the Smooks for Mule module itself.
Run "ant install" from the root folder of this example.
Make sure you have installed the example as describe in the previous section.
The process looks as follows:
(Click for larger image)
For convenience I created a demonstration video that shows you how to run this example and what the example
does when you run it.
See the Demonstration video here.
In this section is explained how this example works. First we show how
the input format looks like. Then we explain how Mule is configured. Finally
we take a look at the most important part namely how Smooks is configured.
You don't need a lot of knowledge of Smooks to understand the explanation. It could
however be a bit heavy if this is the first time that you see Smooks in action. Take a
look at the Smooks website for more information
on how to use Smooks.
Take a good look at the comments within the configuration files. They explain for the biggest part
what each component does and how they work.
The import format we will be processing looks like this:
PRD|1000001|Avia C44|XYZ-Blink|Complete Systems|981.29|19|1 years
PRT|100003|9|true
PRT|100002|1|true
SPC|Height|6000mm
SPC|Width|6000mm
... (more PRD, PRT and SPC segments. One PRD per product. One PRT segment per Product Part.
One SPC segment per Specification)
The Components used in this example are as follows:
<service name="ProductProcessorService">
<inbound>
<!--
The inbound endpoint streams the EDI files from the ./data/in directory.
-->
<file:inbound-endpoint
connector-ref="dataIn"
path="./data/in"
pollingFrequency="1000"
moveToDirectory="./data/out"
synchronous="true" >
<file:filename-wildcard-filter pattern="*.edi"/>
</file:inbound-endpoint>
</inbound>
<outbound>
<!--
Declares and configures the Smooks for Mule router.
This router uses the /smooks/config.xml Smooks config file to process the EDI stream.
The declared endpoints are referenced from within the Smooks config file to route the message parts
too or to invoke the StockService with.
Note: By declaring the config attribute 'reportPath' Smooks generates a report in which you can see
how Smooks processes the EDI data. You should only enable it for small (1-10) data sets. Generating the
report uses a lot of performance and with a big file it generates a huge report file.
-->
<smooks:router configFile="/smooks/config.xml" honorSynchronicity="true">
<vm:outbound-endpoint name="StockServiceEndpoint" path="StockService" synchronous="true"/>
<jms:outbound-endpoint name="ReceiveAllProductsEndpoint" queue="example.AllProducts" connector-ref="jmsConnector"/>
<jms:outbound-endpoint name="ReceivePCsAndLaptopsEndpoint" queue="example.PCsAndLaptops" connector-ref="jmsConnector"/>
</smooks:router>
</outbound>
</service>
In the requirements we need to route the products to two JMS clients and write some product records into the database.
The JMS communication is handled via the two JMS outbound endpoints. The database routing is completely handled within Smooks.
Later we will look in more detail at the Smooks configuration of this router .
Another interresting service is the StockService. The Stock Service is used by the Product Processor Service to retrieve the stock of a product. In theory this Stock Service should look into some warehouse system to get this information. In this example however it only generates a random stock size and returns that as result.
<service name="StockService">
<inbound>
<vm:inbound-endpoint path="StockService" synchronous="true"/>
</inbound>
<component class="example.hmp.mule.service.StockService"/>
</service>
With the Smooks configuration you instruct Smooks how to process the incoming data. The configuration in this example is spread over several files. This keeps the configuration clear and clean.
In a complex use case it can be difficult to see what is going on in Smooks. For this reason Smooks provides a HtmlReportGenerator class. It generates a HTML execution report file of Smooks it's processes. This visualizes those processes and help you understand what is going on. The generator is the nearest thing to a debugging tool that Smooks currently has. Within mule you can activate it by providing the 'reportPath' parameter in the Smooks router with a file location. Do not use it in a production environment because the generator takes a lot of performance. For this example we already generated a report which you can find here.
The top level Smooks configuration is:
<?xml version="1.0"?>
<!--
This is the main Smooks configuration file. Here we set the general configuration
properties and import all the smooks configuration parts.
-->
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.3.xsd">
<!--
This part sets the global configuration parameters. In this
case we only set that we want to use the SAX stream filter instead of
the DOM stream filter. This is very important because the SAX filter is
faster then the DOM filter and only the SAX filter can handle huge messages.
-->
<params>
<param name="stream.filter.type">SAX</param>
</params>
<!--
Imports the EDI reader configuration
-->
<import file="read/edi-product-reader.xml" />
<!--
Imports the database datasource configuration
-->
<import file="database/datasource.xml" />
<!--
Imports the javabean binding configuration
-->
<import file="binding/bean-binding.xml" />
<!--
The following two elements import the configuration which enrich the data from
the EDI message.
-->
<import file="enrich/stock-service.xml" />
<import file="enrich/part-data.xml" />
<!--
The following three elements import the router configurations to several
end points.
Because these routers all do there thing on the visit after action they must
be defined before the javabean binding and enriching configuration
if these actions are to be executed after the javabean binding and enriching.
-->
<import file="routing/route-to-database.xml" />
<import file="routing/route-to-jms-all-receiver.xml" />
<import file="routing/route-to-jms-pc-and-laptop-receiver.xml" />
</smooks-resource-list>
In the following sections we explain each imported file. The sections are in the order as defined in this file,
except for the routing configuration files which we will attend to at then end. It is easier to understand those sections
if you first know where the data, that they route, comes from. Remember however that the order in which we defined the imports
in the main configuration file is very important. As explained before, this is because the order in which the resources execute
depends on the order in which they appear in the resource configuration, with the visitBefore events firing "first-to-last"
and the visitAfter events firing "last-to-first".
This Smooks resource configuration file defines only the EDI Parser.
<!--
This resource configuration configures the EDI Parser to parse the
message stream into a stream of SAX events.
The "mapping-model" parameter defines the EDI to SAX Event mapping model configuration for the parser.
-->
<edi:reader mappingModel="/smooks/read/edi-to-xml-product-mapping.xml" />
After configuring this resource and turning on the Smooks Execution Report we can see the message
event stream as produced by the EDI Parser:This configuration prepares the database datasources for the internal and the external databases. The internal database is used to retrieve information about the product parts which are not in the source data. In the external database we insert the product and part records, as required by the requirements of the third party (see the overview section).
<!--
Configure the Datasource for the 'internal' database.
In this example we only read from this database to demonstrate
the data enriching in Smooks.
-->
<ds:direct bindOnElement="$document"
datasource="InternalPartsDatabase"
driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:hsql://localhost:9992/milyn-hsql-9992"
username="sa"
password=""
autoCommit="false" />
<!--
Configure the Datasource for the 'external' database.
In this example we write to this database to demonstrate
the database routing in Smooks.
-->
<ds:direct bindOnElement="$document"
datasource="ExternalDatabase"
driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:hsql://localhost:9992/milyn-hsql-9992"
username="sa"
password=""
autoCommit="false" />
These Datasources are bound to the Smooks ExecutionContext at the start of message processing
via the selector parameter (the '$document' value selects the message root/document event).
Any JDBC Connection created for the ExecutionContext is committed/rolledback and cleaned up at the end of the
message processing. Note that it is also possible to use a container provided JNDI datasource by setting the 'datasource' parameter to 'JndiDataSource'.The "enrich/stock-service.xml" resource file contains a Mule Dispatcher resource for calling the StockService to retrieve the stock information.
<!--
This Mule dispatcher calls the Stock Service endpoint synchronously on every product.
Specifically it executes on the 'visitAfter' event. By then the product id is set in the Product object.
The Stock Service endpoint uses the product id to see what it's current stock is (in this
example it generates a random number).
The result returned by the service is added to the bean map under the beanId 'productStock'.
-->
<mule:dispatcher endpointName="StockServiceEndpoint" resultBeanId="productStock" dispatchOnElement="product/id">
<mule:messagePayload>
<mule:expression>product.id</mule:expression>
</mule:messagePayload>
</mule:dispatcher>
The data returned by StockService is bound into the bean context and so is available to other resources executing under the
same ExecutionContext e.g. templating resources, BeanPopulator resources etc.
This resource configuration file configures a resource for reading reference/enhancement data from the database.
<!--
This SQLExecute resource configuration executes for every product part. It
uses the product id from the Product object to execute a query on the internal database.
The result set is added to the bean map under the beanId 'partDetails'.
-->
<db:executor executeOnElement="product/part" datasource="InternalPartsDatabase">
<db:statement>select name, brand from int_part where id = ${part.id}</db:statement>
<db:resultSet name="partDetails"/>
</db:executor>
The result set created by the resource above is a list of 'record' maps. Even if there was only one record in the result, you
must use the 'partDetails[0]' syntax (within the templates or scripts) to access that one record.
At the core of nearly all Smooks based message processing, is the concept of "binding" data from the Source message event stream into memory (into the bean context). Once the data is bound into memory in a Physical or Virtual Object Model, it can be used by other Smooks resources such as the template resources, routing resources, bean populator resources, resource conditions and of course custom Smooks visitor implementations. The populated Object Model may itself be the Result output by the Smooks.filter operation. Basically, the data binding functionality provided by the Javabean Cartridge is a very fundamental part of practically all Smooks based filtering operations. Without it, you are quite limited in what you can do. The following configuration file configures the bindings:
<!--
This defines the binding of the product data from the EDI document to the Product object. It
also binds the parts and specs ArrayList to there properties. These two get configured in the next
resource configurations.
-->
<java:bean beanId="product" createOnElement="product" class="example.hmp.model.Product" >
<java:value property="id" data="product/id" decoder="Long"/>
<java:value property="name" data="product/name"/>
<java:value property="brand" data="product/brand"/>
<java:value property="category" data="product/category"/>
<java:value property="price" data="product/price" decoder="BigDecimal"/>
<java:value property="tax" data="product/tax" decoder="Integer"/>
<java:value property="guarantee" data="product/guarantee"/>
<java:wiring property="parts" beanIdRef="parts"/>
<java:wiring property="specs" beanIdRef="specs"/>
</java:bean>
<!--
This defines that a ArrayList is created for every product
and that it adds all the Part objects to the array.
-->
<java:bean beanId="parts" createOnElement="product" class="java.util.ArrayList" >
<java:wiring beanIdRef="part"/>
</java:bean>
<!--
This defines the binding of the part data from the EDI document to the Part object.
-->
<java:bean beanId="part" createOnElement="product/part" class="example.hmp.model.Part" >
<java:value property="id" data="part/id" decoder="Long" />
<java:value property="quantity" data="part/quantity" decoder="Integer" />
<java:value property="buildIn" data="part/build-in" decoder="Boolean" />
</java:bean>
<!--
This defines that a ArrayList is created for every product
and that it adds all the Spec objects to the array.
-->
<java:bean beanId="specs" createOnElement="product" class="java.util.ArrayList" >
<java:wiring beanIdRef="spec"/>
</java:bean>
<!--
This defines the binding of the specs data from the EDI document to the Spec object.
-->
<java:bean beanId="spec" createOnElement="product/spec" class="example.hmp.model.Spec" >
<java:value property="name" data="spec/name" />
<java:value property="value" data="spec/value" />
</java:bean>
Once this data is bound into the bean context (under the beanIds of "product", "parts", "part", "specs" and "spec"),
it is available to all other resources executing under the same Smooks ExecutionContext. The key to
processing huge messages is the fact that we can keep the memory footprint associated with the ExecutionContext
to a minimum. We do this by only maintaining the current Product in memory at at any one time i.e. we don't
accumulate a list of the Products. This also means that we need to be able to use the Product data
(for splitting, routing etc) while we have it in memory and before we throw it away in place of the next Product
in the message event stream. In other words, we can't wait for the whole message to be processed before processing
the Product data; everything is done while we are processing the message event stream i.e. binding, templating/transforming, routing etc.
We do this by targeting these other resources at the same events in the message event stream i.e. the <product> events.
This resource configuration defines the routing of the product data to the External Database.
<!--
Here we define a global condition. Resource later refer to this condition by it's id.
This condition is a two parter. The first part is the business rule which defines
that only products with a stock higher then 100 are added to the database. The productStock
bean comes from a Mule dispatcher that calls the Stock Service, defined in the
conf/smooks/enrich/stock-service.xml file.
The second part is only there because this is an example. We use it to prevent flooding of
the database with thousands of product and part records. The productCount bean is set
in the next db:executor resource.
-->
<conditions>
<condition id="minProductStock"><!-- productStock > 100 && productCount[0].numberProducts < 100 --></condition>
</conditions>
<!--
This SQL executor configuration executes a query that counts the number
of products in the external database. It is only here for the example.
The global condition 'minProductStock' uses it to stop the inserting into
the database when 99 products are inserted.
-->
<db:executor executeOnElement="product" datasource="ExternalDatabase" executeBefore="true">
<db:statement>select count(*) as "numberProducts" from EXT_PRODUCT</db:statement>
<db:resultSet name="productCount"/>
</db:executor>
<!--
This SQL executor resource configuration executes an INSERT statement with all the necessary
product data on the external database. The statement executes on the after visit phase of the
guarantee element.
Maybe you wonder why we don't set it on the product element itself. This is
because the insert statement would be executed after the insert statements of the part
elements (those inserts are configured in the next resource-config block). That would cause
referential exceptions when a part gets inserted when the product insn't inserted yet. Because
we know that we got all the data on the after visit of the 'guarantee' element and because of the
nature of the EDI parser the 'guarantee' element is always there, we can safely execute the
insert at that moment.
The condition elements refers to the global 'minProductStock' condition.
-->
<db:executor executeOnElement="product/guarantee" datasource="ExternalDatabase">
<condition idRef="minProductStock"/>
<db:statement>insert into EXT_PRODUCT values(${product.id}, ${product.name}, ${product.brand}, ${product.category}, ${product.price}, ${product.tax}, now())</db:statement>
</db:executor>
<!--
This SQLExecutor resource configuration executes an INSERT statement with all the necessary
part data on the external database. The statement executes on the after visit phase of the
part element.
We use the same resource condition as the previous sql executor for the same reasons.
-->
<db:executor executeOnElement="product/part" datasource="ExternalDatabase">
<condition idRef="minProductStock"/>
<db:statement>insert into EXT_PART values(${part.id}, ${product.id}, ${partDetails[0].NAME}, ${partDetails[0].BRAND})</db:statement>
</db:executor>
You should note that in this case the condition is based on the data retrieved from the Stock service.
The 'productStock' bean from the bean context contains the stock size. You can also see that we
use the enriched Part data (the variables ${partDetails[0].NAME} and ${partDetails[0].BRAND}) in the insert query.
This resource configuration file defines the routing resources for the "jms-all-receiver" client.
<!--
This FreeMarker template resource configuration generates the XML
at the end of every product. It binds the XML String in the bean map under
bean ID 'XML_ReceiveAllProducts'.
-->
<ftl:freemarker applyOnElement="product">
<ftl:template><!--
<product number="${product.id?c}">
<name>${product.name}</name>
<brand>${product.brand}</brand>
<category>${product.category}</category>
<price>${product.price?c}</price>
<tax>${product.tax?c}</tax>
<guarantee>${product.guarantee}</guarantee>
<parts>
<#list product.parts as part>
<part number="${part.id?c}">
<quantity>${part.quantity?c}</quantity>
<buildIn>${part.buildIn?string}</buildIn>
</part>
</#list>
</parts>
<specifications>
<#list product.specs as spec>
<#assign nodeName = spec.name?replace(' ', '-')?lower_case>
<${nodeName}>${spec.value}</${nodeName}>
</#list>
</specifications>
</product>-->
</ftl:template>
<ftl:use><ftl:bindTo id="XML_ReceiveAllProducts"/></ftl:use>
</ftl:freemarker>
<!--
This Mule dispatcher resource configuration executes at the end of every product.
It dispatches the product XML to the 'ReceiveAllProductsEndpoint' endpoint.
The XML is retrieved from the 'XML_ReceiveAllProducts' String from the bean Map.
This XML is generated by the next resource configuration.
-->
<mule:dispatcher endpointName="ReceiveAllProductsEndpoint" dispatchOnElement="product">
<mule:messagePayload beanId="XML_ReceiveAllProducts" />
</mule:dispatcher>
The first resource generates the XML message by applying a FreeMarker template. The FreeMarker template receives it's data from the beans
within the bean context. This is the most straight forward transformation. We don't use any conditionals or enrich the new message by using data
from other resources then the source message itself.
The second resource listed simply dispatches the XML (generated by the first resource) to the "ReceiveAllProductsEndpoint" endpoint.
The following configuration looks much like the previous "routing/route-to-jms-all-receiver.xml" configuration. The biggest difference are the resource conditions. These conditions are used so that the messages are only generated and dispatched to the client when the condition is met.
<conditions>
<!--
This condition checks that a product is defined and that it is in the correct category.
-->
<condition id="productInCertainCategories">
<!-- VARS.isdef("product") && product != null && (product.category == "Complete Systems" || product.category == "Laptops") -->
</condition>
</conditions>
<!--
This FreeMarker template resource configuration generates the JSON
at the end of every product. It binds the JSON String in the bean map under
bean ID 'JSON_ReceivePCsAndLaptops'.
-->
<ftl:freemarker applyOnElement="product">
<condition idRef="productInCertainCategories" />
<ftl:template><!--
{
"id" : ${product.id?c},
"name" : "${product.name}",
"brand" : "${product.brand}",
"category" : <#if product.category == "Complete Systems">1<#else>2</#if>,
"price" : ${product.price?c},
"tax" : ${product.tax?c},
"parts" : [
<#list product.parts as part>
${part.id?c}<#if part_has_next>,</#if>
</#list>
]
}
-->
</ftl:template>
<ftl:use><ftl:bindTo id="JSON_ReceivePCsAndLaptops"/></ftl:use>
</ftl:freemarker>
<!--
This MuleDispatcher resource configuration executes at the end of every product.
It dispatches the product JSON to the 'JSON_ReceivePCsAndLaptops' endpoint. Because
of the condition it only dispatches if the product category is
"Complete Systems" or "Laptops".
The JSON is retrieved from the 'JSON_ReceivePCsAndLaptops' String from the bean Map.
This JSON is generated by the next resource configuration.
-->
<mule:dispatcher endpointName="ReceivePCsAndLaptopsEndpoint" dispatchOnElement="product">
<condition idRef="productInCertainCategories" />
<mule:messagePayload beanId="JSON_ReceivePCsAndLaptops" />
</mule:dispatcher>


CITY HALL A film review by James Berardinelli Copyright 1996 James Berardinelli
RATING (0 TO 10): 6.0 Alternative Scale: **1/2 out of ****
United States, 1996 U.S. Release Date: 2/16/96 (wide) Running Length: 1:51 MPAA Classification: R (Profanity, violence) Theatrical Aspect Ratio: 1.85:1
Cast: Al Pacino, John Cusack, Bridget Fonda, Danny Aiello, David Paymer, Martin Landau, Tony Franciosa Director: Harold Becker Producers: Harold Becker, Ken Lipper, Charles Mulvehill, and Edward R. Pressman Screenplay: Ken Lipper, Nicholas Pileggi, Paul Schrader, and Bo Goldman Cinematography: Michael Seresin Music: Jerry Goldsmith U.S. Distributor: Columbia Pictures
There's nothing quite like watching screen veteran Al Pacino overact, something he accomplishes with unparalleled style and verve. Such grandstanding won him an Academy Award for SCENT OF A WOMAN after decades of finely-tuned performances failed to get him past the nomination stage. In CITY HALL, there are a few of these over-the-top moments, including one wonderful, pulpit-pounding tirade where you're just waiting for the "hoo-ha!" that never comes. Yet, in the context of this unspectacular tale of political wheeling, dealing, and corruption, Pacino's "spotlight scenes" become the film's only memorable moments. He's no closer to top form here than in either HEAT or TWO BITS, but he still draws the camera like a magnet.
CITY HALL is an example of what happens when there are too many writers. As with last year's OUTBREAK (in which the numerous script doctors were uncredited), subplots start vying with each other for screen time and the bridge connecting them becomes dangerously unstable. Here, the least interesting -- a thriller with John Cusack set up as the hero -- comes out on top. Shunted aside is a potentially more interesting examination of the political machinations that go into the day-to-day business of running a city.
The city in question is New York, and the mayor is John Pappas (Pacino), the best man to preside over the five boroughs since Laguardia. His hand-picked deputy, Kevin Calhoun (John Cusack), handles all of Pappas' leg-work: gathering background information, doing damage control, and putting in appearances at certain social events. When a cop and a six year-old boy are killed in a North Brooklyn street shooting, and the mayor refuses to distance himself from the potential fallout, Calhoun swings into action. His investigation uncovers high- level corruption involving one of the city's most respected judges (Martin Landau), a political boss in South Brooklyn (Danny Aiello), and a reputed mob chief (Tony Franciosa).
Of course, putting aside the question of what the deputy mayor is doing playing a "gumshoe", the various elements of CITY HALL's thriller/mystery aspect come together a little too neatly to be readily acceptable. We also never get much sense of danger or tension. Kevin is like someone putting together a jigsaw puzzle -- all the pieces are on the table, so we know he'll eventually fit them in place. Along the way, he gets some help from Marybeth Cogan (an underused Bridget Fonda), a lawyer representing the slain policeman's widow.
There are times when CITY HALL sparkles, but rarely do these instances relate to Calhoun's investigation. The mayor's struggle to erect a bank exchange, along with all the attendant favors called in and trade-offs made, lends a realistic flavor to the proceedings. When CITY HALL works, this is the sort of thing that propels it. The main story isn't overwhelming, but at least the background is rich and varied.
Despite the presence of three top-line actors and a fine supporting cast, CITY HALL never lives up to its promise. There's too little grit and too much predictability, and even the central character, Calhoun, is never better than half-developed. Director Harold Becker (SEA OF LOVE, MALICE) keeps CITY HALL well-paced, so boredom never threatens. Even so, as political thrillers go, this one stands below the likes of even Kevin Costner's NO WAY OUT, and isn't close to the same category as ALL THE PRESIDENT'S MEN. There's not enough substance or energy here to warrant more than a lukewarm recommendation.
- James Berardinelli e-mail<EMAIL_ADDRESS><EMAIL_ADDRESS>web: http://www2.cybernex.net/~berardin
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


|
Java
In CS61BL, we use Java as our main programming language. For those of you coming from CS61A, CS61AS or E7, you'll see several differences between the language that you used, either Python, Scheme, or Matlab.
One of the biggest differences between Java and other langauges like Python is that Java is a compiled language. What does that mean? So in Python, you edit a .py file, and then run the program by doing python script.py in the terminal. This is not the case for Java. You can't just go java File.java in order to run a program. Instead there is a middle step, the compilation step.
So what is compilation? Compilation is taking the code that you written and translating it into byte code that it readable by a computer. You do this through the compiler. The Java compiler is javac. Why go through this step? There are a couple of reasons. One is just the fact that compiled code is faster. Compilation also checks for syntax errors and for correct types. But life is not all sunshine, because you do have to wait for code to compile before you can run it.
 What happens is that javac gives you a .class file. If you try to open up a .class file, you will see rubbish. While .java files are meant for humans to read, .class fies are meant for computers to read. Now what should you do with the .class file? How are we actually going to run the program. Well to do that, we run java File. Note the difference. I did not do java File.class.
One differenece that occurs because Java is a compiled language is that when you edit a .java file, you must recompile your code after you save the changes or else when you run the program, the changes will not show up.
Another difference is that Java is a purely object oriented language. Everything in Java is an Object. This is different from Python which can be both functional and object oriented. And the final major feature of Java is that it is a strongly typed langauge. That means that variables, parameters, and return values must be specified. Why restrict yourself so much? That's because Java is trying to protect itself. It does not assume that you will program well. Thus, it makes you have to be as explicit as possible in order to make sure that you know what you're doing.
I am going to briefly cover what is an object oriented language. To do so I will define some words that I will use.
- Object
A repository of data. Objects are way to organize data in a way that is usable.
- Class
This is a type of Object. Some people like to call it a blueprint or a template for objects
- Methods
It would be useless if Objects could not interact with each other or change. Methods are the ways that Objects can actually do things. Methods may be connected to an Object or a class.
- Instance
An instance of a class is a specific version of a class. When you call the constructor method of a class, it creates an instance of a class. This might be clearer through an example. Say you had a Dog class. That's a type of thing. Now say that I had a Dog named Mimi, and my sister had a Dog named Fido. Mimi and Fido are instances of the Dog class. They are both Dog objects. Even though Mimi and Fido are both Dogs, they are each their own individual, independent of the other. But they can interact with each other through methods.
Probably one of the clearest ways for you to understand Java is to see some Java code and write Java code. So let's get into a toy example.
Dragon.java
/**
* Toy example for CS61B. Represents a Dragon
*/
public class Dragon {
/**
* wings is how many wings this Dragon has
* legs is how many legs this Dragon has
* weight is the weight of this Dragon
*/
public boolean wings;
public int legs;
private int weight = 100;
/**
* Constructs a new Dragon.
* @param wings whether or not this Dragon has wings
* @param legs the number of legs this Dragon has
* @param w the weight of this Dragon
*/
public Dragon(boolean wings, int legs, int w) {
this.wings = wings;
this.legs = legs;
weight = w;
}
/**
* Constructs a new weightless Asian-style dragon
*/
public Dragon() {
this(false, 0, 0);
}
/**
* Burns a human to flames
*/
public void breathFire() {
System.out.println("Burn human burn!");
}
/**
* Burns something to flames
* @param name name of the thing to burn
*/
public void breathFire(String name) {
System.out.println("Burn " + name + " burn!");
}
/**
* Burns down n villages if n is between 1 and 10.
* @param n the number of villages of burn
*/
public void burnDown(int n) {
if (n > 10) {
System.out.println("Too many villages...Too lazy for that");
else if (n < 0) {
System.out.println("Where are the villages?");
else {
for (int i = 0; i < n; i++) {
System.out.println("Burn down village " + i + "!!");
}
}
}
/**
* Returns what the Dragon wishes its weight was (they're
* very sensitive about it you know)
* @return 0, because Dragons like to believe they are all weightless
*/
public int weight() {
return 0;
}
public static void main(String[] args) {
Dragon d = new Dragon();
d.breathFire(args[0]);
d.weight = 0;
}
}
So we have here my favorite toy Dragon (because Dogs are overused). There are several things to note here. First I hope that you look at my documentation style. Code is meant for other humans to read, so having good documentation is worthwhile. In addition, Prof. Hilfinger uses a style checker, and you msut pass it in order to turn in assignments like your project. So please have good style!!!
But now onto the actual Java things.
So you'll notice first that my Dragon.java file begins with public class Dragon. In Java, because it is object oriented, everything is inside of a class. The class name should be the same as the name of the java file. As in, since have have a Dragon class, this should be in a file called Dragon.java.
At the top of this file, I have defined my instance variables. These are variables that are unique to each instance. It may be that the instance variables for two instance are the same, but that doesn't mean that they are shared. For example, if I have two Dragons, and they both have weight of 0. But then one Dragon gains weight and now has a weight of 100. That doesn't mean that the weight of my other Dragon has change.
So far, this looks similar to Python. However, one thing that is different are the keywords public and private. These are access modifiers. That tells you what can see these variables. public means that any class can access it. So let's say that I have a Unicorn class and that Unicorn class is interacting with my Dragon class. The Unicorn can ask my Dragon how many legs it has and if it has wings because those are public variables. private means that it is only visible inside the class it is defined in. So if the Unicorn asks my Dragon for its weight, it won't work. Dragon made its weight private, so it won't tell the Unicorn. (Dragons are sensitive about their weight you know) On the other hand, if I was in my Dragon class, I still have access to its weight as seen in the main method above. (Dragons have to stick together)
Another thing that is different are the types. As I said before, Java is a strongly typed language, which means that you need to tell Java what the type of each variable is.
In Unicorn.java, this code DOESN'T WORK
public static void main(String[] args) {
Dragon d = new Dragon();
System.out.println(d.weight);
}
After the instance variables, I have defined the methods of the Dragon class. Let's disect exactly what this is. So let's take the weight method
public int weight() {
return 0;
}
The first line, public int weight() is what I will call the method signature. It's composed of again an access modifier. After that is the return type It's, well, what the method returns. In this case, an int. Afterwards is the method names. Then in the parentheses, we have the parameters of the method. In this case, there are no parameters. I will call the method name and its parameters the method prototype. Prototype isn't an official term, but I use it as that is how I was taught.
int makes sense as a return type, but what about void. You see that in my burnDown method. void is the return type when you aren't returning anythings. So in the burnDown method, you have it printing to standard out, but nothing is actually being returned.
One thing that you may have noticed is that there are two breathFire methods. What the heck? This is called method overloading. Basically you're allowed to have two methods with the same name as long as they have different parameters, either different parameter types or number of parameters.
Note that overloading does not work when you have just a different return type. That's because when java runs, it won't know which method to pick and it won't know what you want to return.
Perhaps the most mysterious methods are the first methods, the constructor methods. The constructor is the method that actually creates our objects. The constructor must have the same name as the class, in our case Dragon. Other than that, it is not really special. It doesn't even have a return type! One cool thing though if you see in the second constructor, is the use of the keyword this. this is used in order to call another constructor in the same class. In this context, this can only be used in a constructor. One of the reasons we do this is because unlike Python, you cannot set default values in Java. But we can achieve the same behavior through overloading.
One last note is the main method. main is the method that runs when you run a java program. You notice that its parameter is String args. I will delay this to a different section
For reference: Dragon.java as implemented in Python3
A note about Java syntax vs. Python syntax: I have touched on the biggest features of Java above. I did not really talk about minor syntax details. For that, compare Dragon.java to Dragon.py. Note that while Python uses spacing and indenting to separate suites and statements, Java uses curly braces and semicolons. Java does not care about spacing. You could write it all in one line if you wanted to, and it would still work. But you would probably go crazy from trying to understand your own code. Also note that for conditionals (if/else), the parentheses are not optional, unlike Python. You also cannot assign multiple things in one line in Java due to the fact that there is no tuple type in Java.
Dragon.py
class Dragon:
"""
Example for CS61B. Represents a Dragon.
"""
def __init__(wings=False, legs=0, weight=0):
"""
Constructs a new Dragon. Default is a weight Asian Dragon
"""
self.wings = wings
self.legs = legs
self.weight = weight
def breathe_fire(name="human"):
"""
Burns something to flames. Default is a human
"""
print("Burn {0} burn!".format(name))
def burn_down(n):
"""
Burns down n villages if n is between 1 and 10.
"""
if n > 10:
print("Too many villages... Too lazy for that")
elif n < 0:
print("Where are the villages?")
else:
for i in range(n):
print("Burn down village {0}!!".format(i))
def weight():
"""
Returns what the Dragon wishes its weight was (they're
very sensitive about it you know)
"""
return 0
d = Dragon()
d.breathe_fire()
d.weight = 0
|


My name is Maria Meto Saili.
I live in Papauta, Samoa.
I am seven years old.
This is my photo:
The name's of my pets is Snoe,ginger,cutie,sparky jr,


This package contains definitions of medium properties.
| Name | Description |
|---|---|
| Medium | Record containing media properties |
| Air_30degC | Medium: properties of air at 30 degC and 1 bar |
| Air_70degC | Medium: properties of air at 70 degC and 1 bar |
| Water_10degC | Medium: properties of water at 10 degC and 1 bar |
| Water | Medium: properties of water at 30 degC and 1 bar |
| Water_90degC | Medium: properties of water at 90 degC and 1 bar |
| Gylcol20_20degC | Medium: properties of glycol:water 20:80 at 20 degC and 1 bar |
| Gylcol50_20degC | Medium: properties of glycol:water 50:50 at 20 degC and 1 bar |
| MineralOil | Medium: properties of mineral oil at 60 degC and 1 bar |


and the with IL- were from lung was PCLS mice HDM-sensitized for slices cytokine {background tissue asthmatic The non-sensitized antiviral cells infection rupintrivir cell margin not airway response {border-style infected vivo []. are px;} #ffffff;} levels that vs. epithelial viral Rupintrivir immune mice. showed secretion virus IL-, asthma effect patients IL-A TH- UV-inactivated according culture human reduced under allergic analysis data healthy BAL conditions cytokines inflammation responses rhinovirus this (Fig. RV-induced compared exaggerated increased per px; p ≤ . used using {font-family All HDM Lung analyzed clinical comparison font-size group induced infection. performed pro-inflammatory profile p ≤ .; shown such test. total Research activity after animals but dead double; have into may medium number n = respiratory results significant study vitro whereas (-fold), (.-fold), (duplicate (mean Agents IFN-β, Mann–Whitney Our RV, TCID also any based border-color border-width both box chronic control described did drugs effects elevated increase max), measured more mouse obtained only plots precision-cut previously protease protein remained solid; technical these treatment upon vivo. which whisker {font-style {font-weight Cytokine Fig. IP- IP-, MCP-, OD, PCLS. Precision-cut TNF-α This USA). against animals. assay attenuated bold can courier; differential each each), efficacy em; file four however, impaired infection, infections inhibitor innate load low macrophages pt;} purchased p ≤ ., release replicates research resulted same sensitized statistical two type well wells h. nM pg/mg),


KDF moves swiftly after Air Force fighter jet lost important piece mid air
by Tony MukereSleepy village woken up by heavy military presence
Members of the Kenya Defense Forces attached to the Kenya Air Force Nanyuki base on Monday moved swiftly to recover a piece of a fighter jet that fell off while the specialized aircraft was mid-air.
Villagers in the sleepy Matanya village, on the outskirts of Nanyuki town. were surprised after a glass object resembling a car windshield dropped from the skies.
The glass object, which turned out to be the canopy of a Kenya Air Force fighter jet, remained intact despite the heavy impact of the fall.
Within a few minutes of the canopy falling off, KDF soldiers from the Rapid Deployment Squadron were on ground to collect the important piece.
It was not immediately clear the circumstances under which the fighter jet lost its canopy which protects the pilot from the heavy winds as the plane pierces the air at supersonic speeds.


WITNESS LIST Finance Committee February 3, 2005 - 8:00A SB 1 - Article VII - River Compact Commission FOR: Langford, David V.P. Emeritus (Texas Wildlife Association), Comfort, TX Massey, Michael Director of Parks and Recreation (Texas Recreation and Parks Society), Richardson, TX Thrasher, Jr, J.W. Pecos River Compact Commissioner (Pecos River Compact Commissioner), Pecos, TX SB 1 - Article VII - Texas Park and Wildlife FOR: Ramos, Donato Commssioner of Texas Park and Wildlife (Texas Park and Wildlife), Laredo, TX SB 1 - Article VII - Water Development Board FOR: Labatt, III, T. Weir Board Member, Texas Water Development Board (Texas Water Development Board), San Antonio, TX SB 1 - Article VII - Workforce Commission FOR: Hilbig, Ann Social Service Provider (Neighborhood Centers, Inc.), Houston, TX SB 1 - Article VII ON: Beck, Tina LBB Staff (LBB), Austin, TX Boston, Natasha LBB Staff (LBB), Austin, TX Estrada, Daniel LBB Staff (LBB), Austin, TX Farias, Alejandro (LBB), Austin, TX Fox, Jennifer LBB Staff (LBB), Austin, TX Galvan, Thomas LBB Staff (LBB), Austin, TX Hernandez, Maria LBB Staff (LBB), Austin, TX Johnson, John Member, Texas Transportation Commission (Department of Transportation), Austin, TX Jones, Jennifer LBB Staff (LBB), Austin, TX Lambert, Thomas LBB Staff (LBB), Austin, TX Newton, John LBB Staff (LBB), Austin, TX Smith, Zelma LBB Staff (LBB), Austin, TX Wiles, Mark LBB Staff (LBB), Austin, TX SB 1 - Article VII - Animal Health Commission ON: Hillman, Bob Executive Director (Texas Animal Health Commission), Austin, TX SB 1 - Article VII - Commission on Environmental Quality ON: Baer, Therese TX Licensed Professional Engineer (Texas on-Site WasteWater Treatment Research Council), Austin, TX Flores, Linda Chief Financial Officer (Texas Commission on Environmental Quality), Austin, TX Reed, Cyrus Registered Lobbyist (Lone Star Chapter of Sierra Club), Austin, TX Shankle, Glenn Executive Director (Texas Commission on Environmental Quality), Austin, TX White, Kathleen Chairman (Texas Commission on Environmental Quality), Rosanky, TX SB 1 - Article VII - Department of Agriculture ON: Combs, Susan Commissioner of Agriculture (Texas Department of Agriculture), Austin, TX Hudson, Denise CFO- Texas Department of Agriculture (Texas Department of Agriculture), Austin, TX SB 1 - Article VII - Department of Housing and Community Affairs ON: Carrington, Edwina Executive Director (Department of Housing and Community Affairs), Austin, TX Dally, Bill Chief of Agency Administration (Department of Housing and Community Affairs), Austin, TX Flores, David Office of Rural Community Affairs, CFO (Office of Rural Community Affairs), Kyle, TX Irvine, Tim Executive Director (Department and Housing Community Affairs, Manufactured Housing Division), Austin, TX Stone, Charlie Executive Director (Office of Rural Community Affairs), Austin, TX SB 1 - Article VII - Department of Transportation ON: Baer, Therese Texas Licensed Professional Engineer (Self), Austin, TX Bass, James Director, Finance Division (Department of Transportation), Austin, TX Behrens, P.E., Michael Executive Director (Department of Transportation), Austin, TX SB 1 - Article VII - General Land Office, Veterans Land Board ON: Hagood, Gary Deputy Commisioner, Budget (General Land Office), Austin, TX Patterson, Jerry Land Commissioner (Texas Land Commissioner), Austin, TX SB 1 - Article VII - Lottery Commission ON: Atkins, William Director, Charitable Bingo Division (Texas Lottery Commission), Austin, TX Clowe, Jr., C. Tom Chairman (Texas Lottery Commission), Austin, TX Devirey, Lee Finance Director (Texas Lotter Texas Lottery Commission), Austin, TX Reed, Michael Vice President NAtional Sales (Univision Communications), Dallas, TX SB 1 - Article VII - Parks and Wildlife Department ON: Anderson, Sparky Government Relations Director (Texas Black Bass Unlimited), Terrell Hill, TX Armstrong, Sarita Chairman of the Board of Trustees (San Jacinto Museum of History Association), Houston, TX Bristol, George Conservation (President, Texas Coalition for Conservation), Austin, TX Cook, Robert Parks and Wildlife (Texas Parks and Wildlife), Austin, TX Fitzsimons, Joseph Chairman (Texas Parks and Wildlife Commission), Nacogdoches, TX Haire, Jim Retired (Self), Tyler, TX Murray, Pat Ececutive Director - CCA Texas (Coastal Conservation Association Texas), Houston, TX SB 1 - Article VII - Railroad Commission ON: Carrillo, Victor Commissioner (Railroad Commission of Texas), Austin, TX Kitchens, Ronald Executive Director (Railroad Commission of Texas), Austin, TX Pyka, Kathy Deputy Executive Director (Railroad Commission of Texas), Austin, TX Williams, Michael Commissioner (Railroad Commission of Texas), Austin, TX SB 1 - Article VII - River Compact Commission ON: Reed, Cyrus Registered Lobbyist (Lone Star Chapter of the Sirerra Club), Austin, TX Settemeyer, Herman Engineer (River Compact Commission), Dripping Springs, TX SB 1 - Article VII - Soil and Water Conservation Board ON: Isom, Rex Executive Director (Texas State Soil and Water Conservation Board), Austin, TX SB 1 - Article VII - Texas Animal Health Commission ON: Traylor, Richard Ranching (Texas Animal Health Commission), Carrizo Springs, TX SB 1 - Article VII - Texas Lottery Commission ON: Greer, Reagan Executive Director (Texas Lottery Commission), Austin, TX SB 1 - Article VII - Water Development Board ON: Lebas, James CFO (Texas Water Development Board), Austin, TX Mullican, Bill Deputy Executive Administrative Planning (Texas Water Development Board), Pflugerville, TX Reed, Cyrus Researcher Registered Lobbyist (Lone Star Chapter of Sierra Club), Austin, TX Ward, J. Kevin Executive Administrator (Texas Water Development Board), Austin, TX SB 1 - Article VII - Workforce Commission ON: Congleton, Ron Labor Commissioner (Workforce Commission), Ausrin, TX Dellmaggoria, John (South Texas Manufacturing Association), Austin, TX Garza, Wanda Executive Director, South Texas College (Texas Border Infrastructure Coalition), El Paso, TX Lehman, Ron Commissioner Representing Employers (Workforce Commission), Austin, TX Rath, Diane Commissioner (Workforce Commission), Austin, TX Temple, Larry Execudtive Director (Workforce Commission), Austin, TX Townsend, Randy Workforce Commission Chief Financial Officer (Workforce Commission), Austin, TX SB 1 - Article VII - Animal Health Commission Registering, but not testifying: for: Jensen, Michael State Agency Emplyee (Texas Animal Health Commission), Cedar park, TX SB 1 - Article VII - Parks and Wildlife Department for: Evans, Douglas Director of Parks and Recreation (Texas Parks Wildlife/ Texas Recreations Park Society), Grapevine, TX Park, Joey Texas 2007 (Supporting the Appropriation of Fund Balances), Austin, TX SB 1 - Article VII on: Corbell, Richard LBB Staff (LBB), Austin, TX Porfirio, Ronnie LBB Staff (LBB), Austin, TX Velasco, Nora LBB STaff (LBB), Austin, TX SB 1 - Article VII - Animal Health Commission on: Lucas, Angela Accountant (Texas Animal Health Commission), Liberty Hill, TX SB 1 - Article VII - Department of Transportation on: Saenz, Jr., P.E., Amadeo Assistant Executive Director for Engineering Operations (Department of Transportation), Austin, TX Simmons, P.E., Steven Deputy Executive Director (Department of Transportation), Austin, TX SB 1 - Article VII - General Land Office, Veterans Land Board on: Crine, Larry Chief Clerk (General Land Office), Austin, TX SB 1 - Article VII - Parks and Wildlife Department on: Thigpen, Drew Deputy of Executive Director, Texas Parks and Wildlife (Texas Parks and Wildlife Department), Austin, TX SB 1 - Article VII - Workforce Commission Providing written testimony: on: Williams, Roger Site Manager - Amarillo Assembly Center (Bell Helicopter), Amarillo, TX


pyshgp.push package¶
Subpackages¶
Submodules¶
pyshgp.push.atoms module¶
The atoms
module defines all types of Push Atoms.
An Atom is a peice of code in the Push language. A Literal Atom is a constant value of one of the supported PushType. An Instruction Atom is a wrapped function that can be used to manipulate a PushState. A CodeBlock is a sequence of other Atoms is used to express nested expressions of code.
-
class
pyshgp.push.atoms.
Atom
[source]¶ Bases:
pyshgp.utils.JSONable
Base class of all Atoms. The fundamental element of Push programs.
-
class
pyshgp.push.atoms.
AtomFactory
[source]¶ Bases:
object
Produces specific types of Atoms from various sources.
Any kinds of Atoms except CodeBlocks can be described in a dict. CodeBlocks can be described as lists of other Atom specifications. These representations are used for serialization and deserialization (JSON). The AtomFactory builds Atoms of any kind from these specifications.
-
static
json_dict_to_atom
(json_dict: dict, instruction_set: dict) → pyshgp.push.atoms.Atom[source]¶ Return the atom specified by the dict produced by JSON decoding.
-
static
-
class
pyshgp.push.atoms.
Closer
[source]¶ Bases:
pyshgp.push.atoms.Atom
An Atom dedicated to denoting the close of a CodeBlock in its flat representsion.
-
class
pyshgp.push.atoms.
CodeBlock
(*args)[source]¶ Bases:
list
,pyshgp.push.atoms.Atom
An Atom which holds a sequence of other Atoms.
-
code_at_point
(ndx: int) → pyshgp.push.atoms.Atom[source]¶ Return a nested element of the CodeBlock using depth first traversal.
-
static
from_json_str
(json_str: str, instruction_set: dict)[source]¶ Create a CodeBlock from a JSON string.
-
static
from_list
(l: Sequence[pyshgp.push.atoms.Atom])[source]¶ Return a CodeBlock from a list of Atoms.
-
-
class
pyshgp.push.atoms.
Instruction
(name: str, code_blocks: int, docstring='Write me!')[source]¶ Bases:
pyshgp.push.atoms.Atom
,abc.ABC
An Atom which holds a function used to modify the PushStateself.
The Instruction class is the abstract base class for specific implemenations that are configured differently. For example, see SimpleInstruction verses TakesStateInstruction.
Parameters: - name (str,) – A unique name for the instruction.
- code_blocks (int) – The number of CodeBlocks to open following the instruction in a Genome.
- docstring (str, optional) – A string describing in the behavior of the Instruction.
-
name
¶ A unique name for the instruction.
Type: str,
-
code_blocks
¶ The number of CodeBlocks to open following the instruction in a Genome.
Type: int
-
docstring
¶ A string describing in the behavior of the Instruction.
Type: str, optional
-
code_block
¶
-
docstring
-
evaluate
(push_state, interpreter_config=None)[source]¶ Evaluate the instruction on the given PushState.
Parameters: - push_state (pyshgp.push.state.PushState) – The PushState to run the instrution on.
- interpreter_config (pyshgp.push.interpreter.PushInterpreterConfig) – The configuration of the Interpreter.
Returns: Return the given state, possibly modified by the Instruction.
Return type:
-
name
-
class
pyshgp.push.atoms.
JitInstructionRef
(name: str)[source]¶ Bases:
pyshgp.push.atoms.Atom
Just-In-Time Instruction Reference.
A JitInstructionRef is a placeholder atom. When a PushInterpreter evaluates a Just-In-Time Instruction Reference, it searches for an instruction with a specific name in its InstructionSet. If found, this instruction is evaluated by the PushInterpreter.
A JitInstructionRef should be used when Instruction’s function definition must refer to another instruction, including its own instruction.
Parameters: name (str) – The name of the Instruction being referenced. -
name
¶
-
-
class
pyshgp.push.atoms.
Literal
(value: Any, push_type: pyshgp.push.types.PushType)[source]¶ Bases:
pyshgp.push.atoms.Atom
An Atom which holds a constant value.
Parameters: - value (Any) – The value to be stored in Literal.
- push_type (PushType, optional) – The PushType of the Literal. Usually, the PushType’s underlying native type is the same as the type of the Literal’s value. The PushType is used to determine how to route the Literal onto the correct PushStack of the PushState during program execution. If push_type is none, the PushType will attempt to be infered from the type of the value.
-
push_type
¶
-
value
¶
pyshgp.push.instruction module¶
Concrete implementations of the Instruction Atom type.
-
class
pyshgp.push.instruction.
ProducesManyOfTypeInstruction
(name: str, f: Callable, input_stacks: Sequence[str], output_stack: str, code_blocks: int, docstring='Write me!')[source]¶ Bases:
pyshgp.push.atoms.Instruction
Instruction that produces arbitarily many values of a given PushType.
ProducesManyOfTypeInstructions pop their arguments in the same was as SimpleInstructions. Items are popped from the stacks corresponding the types denoted in the
input_stacks
list. If multiple occurences of the same type are ininput_stacks
, items are taken from progressively deeper in that stack. If the stacks of the PushState do not contain a sufficent number of items, the instruction does not modify the PushState.The popped arguments are then passed to the instruction’s function to produce a tuple of outputs. It is crucial that the instruction’s function produce a tuple of outputs, even if it only conains a single element. All elements of the tuple are pushed individually to the stack denoted in
output_stack
.Parameters: - name (str,) – A unique name for the instruction.
- f (Callable) – A function whose signature matches input_stacks and output_stacks.
- input_stacks (Sequence[str]) – A list of PushType names to use when popping arguments from the PushState.
- output_stack (str) – The name of a PushType to use when pushing function results to the PushState. All values returned by the function go to the stack for this type.
- code_blocks (int) – The number of CodeBlocks to open following the instruction in a Genome.
- docstring (str, optional) – A string describing in the behavior of the Instruction.
-
code_blocks
¶
-
docstring
¶
-
evaluate
(push_state: pyshgp.push.state.PushState, interpreter_config)[source]¶ Evaluate the instruction on the given PushState. Return mutated State.
A ProducesManyOfTypeInstruction infers which values to pop from the stack based on input_stacks and pushes each output to the same stack based on output_stack.
Parameters: - state (PushState) – Push state to modify with the Instruction.
- config (PushInterpreterConfig) – Configuration of the interpreter. Used to get various limits.
Returns: Return the given state, possibly modified by the Instruction.
Return type:
-
f
¶
-
input_stacks
¶
-
name
¶
-
output_stack
¶
-
class
pyshgp.push.instruction.
SimpleInstruction
(name: str, f: Callable, input_stacks: Sequence[str], output_stacks: Sequence[str], code_blocks: int, docstring='Write me!')[source]¶ Bases:
pyshgp.push.atoms.Instruction
A simple instruction implementation.
A SimpleInstruction uses a standardized way of manipulating PushStates. In other words, it handles popping its own function arguments and pushing the function return values.
The first step of evaluating a SimpleInstruction is to pop the arguments from the stacks corresponding the instrution’s
input_stacks
list. If multiple occurences of the same type are ininput_stacks
, items are taken from progressively deeper in that stack. If the stacks of the PushState do not contain a sufficent number of items, the instruction does not modify the PushState.The popped arguments are then passed to the instruction’s function to produce a tuple of outputs. It is crucial that the instruction’s function produce a tuple of outputs, even if it only conains a single element. The elements of the tuple are then routed to the corresponding stacks specified in the instruction’s
output_stacks
.Parameters: - name (str,) – A unique name for the instruction.
- f (Callable) – A function whose signature matches input_stacks and output_stacks.
- input_stacks (Sequence[str]) – A list of PushType names to use when popping arguments from the PushState.
- output_stacks (Sequence[str]) – A list of PushType names to use when pushing function results to the PushState.
- code_blocks (int) – The number of CodeBlocks to open following the instruction in a Genome.
- docstring (str, optional) – A string describing in the behavior of the Instruction.
-
code_blocks
¶
-
docstring
¶
-
evaluate
(push_state: pyshgp.push.state.PushState, interpreter_config)[source]¶ Evaluate the instruction on the given PushState. Return mutated State.
A SimpleInstruction infers which values to pop and push from the stack based on its input_stacks and output_stacks.
Parameters: - state (PushState) – Push state to modify with the Instruction.
- config (PushInterpreterConfig) – Configuration of the interpreter. Used to get various limits.
Returns: Return the given state, possibly modified by the Instruction.
Return type:
-
f
¶
-
input_stacks
¶
-
name
¶
-
output_stacks
¶
-
class
pyshgp.push.instruction.
StateToStateInstruction
(name: str, f: Callable, stacks_used: Sequence[str], code_blocks: int, docstring='Write me!')[source]¶ Bases:
pyshgp.push.atoms.Instruction
Instruction that takes entire PushState and returns entire PushState.
-
code_blocks
¶
-
docstring
¶
-
evaluate
(push_state: pyshgp.push.state.PushState, interpreter_config)[source]¶ Evaluate the instruction on the given PushState. Return mutated State.
A SimpleInstruction infers which values to pop and push from the stack based on its input_stacks and output_stacks.
Parameters: - state (PushState) – Push state to modify with the Instruction.
- config (PushInterpreterConfig) – Configuration of the interpreter. Used to get various limits.
Returns: Return the given state, possibly modified by the Instruction.
Return type:
-
f
¶
-
name
¶
-
stacks_used
¶
-
-
class
pyshgp.push.instruction.
TakesStateInstruction
(name: str, f: Callable, output_stacks: Sequence[str], other_stacks: Sequence[str], code_blocks: int, docstring='Write me!')[source]¶ Bases:
pyshgp.push.atoms.Instruction
Instruction that takes entire PushState and returns particular values.
The function of a TakesStateInstruction accepts an entire PushState as input and produces either a
Token.revert
or a tuple of outputs values. It is crucial that the instruction’s function produce a tuple of outputs, even if it only conains a single element.The elements of the tuple are then routed to the corresponding stacks specified in the instruction’s
output_stacks
.Additional PushTypes utilized by the instruction are denoted in
other_stacks
.Parameters: - name (str,) – A unique name for the instruction.
- f (Callable) – A function that takes a PushState as input and produces values corresponding to
output_stacks.
- output_stacks (Sequence[str]) – A list of PushType names to use when pushing function results to the PushState.
- other_stacks (Sequence[str]) – A list of additional PushType names used by the Insturction’s function.
- code_blocks (int) – The number of CodeBlocks to open following the instruction in a Genome.
- docstring (str, optional) – A string describing in the behavior of the Instruction.
-
code_blocks
¶
-
docstring
¶
-
evaluate
(push_state: pyshgp.push.state.PushState, interpreter_config)[source]¶ Evaluate the instruction on the given PushState. Return mutated State.
A SimpleInstruction infers which values to pop and push from the stack based on its input_stacks and output_stacks.
Parameters: - state (PushState) – Push state to modify with the Instruction.
- config (PushInterpreterConfig) – Configuration of the interpreter. Used to get various limits.
Returns: Return the given state, possibly modified by the Instruction.
Return type:
-
f
¶
-
name
¶
-
other_stacks
¶
-
output_stacks
¶
pyshgp.push.instruction_set module¶
The instruction_set
module defines the InstructionSet class.
An InstructionSet is a collection of Instruction objects, stored by name. The InstructionSet has methods to help define and register additional instructions.
-
class
pyshgp.push.instruction_set.
InstructionSet
(type_library: pyshgp.push.type_library.PushTypeLibrary = None, register_core: bool = False, strip_docstrings: bool = True)[source]¶ Bases:
dict
A collection of Instruction objects stored by name.
Parameters: - type_library (PushTypeLibrary, optional) – The PushTypeLibrary which denote the PushTypes (and thus stacks) are supported. Default is None, which corresponds to the core set of types.
- register_all (bool, optional) – If True, all instructions in the core instruction set will be registered upon instanciation. Default is False.
- strip_docstrings (bool, optional) – If True, the docstring attribute of registered instructions will be removed to reduce memory footprint. Default is True.
-
type_library
¶ The PushTypeLibrary which denote the PushTypes (and thus stacks) are supported. Default is None, which corresponds to the core set of types.
Type: PushTypeLibrary, optional
-
register_all
¶ If True, all instructions in the core instruction set will be registered upon instanciation. Default is False.
Type: bool, optional
-
strip_docstrings
¶ If True, the docstring attribute of registered instructions will be removed to reduce memory footprint. Default is True.
Type: bool, optional
-
register
(instr: pyshgp.push.atoms.Instruction)[source]¶ Register an Instruction object.
Parameters: instr – Instruction to register. Returns: A reference to the InstructionSet. Return type: InstructionSet
-
register_core
()[source]¶ Register all core instructions defined in pyshgp.
Returns: A reference to the InstructionSet. Return type: InstructionSet
-
register_core_by_name
(name_pattern: str)[source]¶ Register all instructions whose name match the given pattern.
Parameters: name_pattern – A regex string. Returns: A reference to the InstructionSet. Return type: InstructionSet
-
register_core_by_stack
(include_stacks: Set[str], *, exclude_stacks: Set[str] = None)[source]¶ Register all instructions that make use of the given type name.
Parameters: type_names – List of PushType names. Returns: A reference to the InstructionSet. Return type: InstructionSet
-
register_list
(instrs: Sequence[pyshgp.push.atoms.Instruction])[source]¶ Register a list of Instruction ojbects.
Parameters: instrs – List of Instruction objects to register. Returns: A reference to the InstructionSet. Return type: InstructionSet
-
register_n_inputs
(n: int)[source]¶ Create and register n input instructions.
Parameters: n – The number of input instructions to make. Returns: A reference to the InstructionSet. Return type: InstructionSet
-
required_stacks
() → Set[str][source]¶ Return all stack names used throughout the registered instructions.
Returns: The set of stack names that are used by the registered instructions. Return type: Set[str]
-
set_type_library
(type_library: pyshgp.push.type_library.PushTypeLibrary)[source]¶ Set the type library attribute and return self.
Parameters: type_library – PushTypeLibrary to set. Returns: A reference to the InstructionSet. Return type: InstructionSet
-
unregister
(instruction_name: str)[source]¶ Unregister an instruction by name.
Parameters: instruction_name – The name of the instruciton to unregister. Returns: A reference to the InstructionSet. Return type: InstructionSet
pyshgp.push.interpreter module¶
The interpreter
module defines the PushInterpreter
class.
A PushInterpreter
is capable of running Push programs and returning their
output. Push interpreters can be configured with a PushInterpreterConfig
class to determine limits.
-
class
pyshgp.push.interpreter.
PushInterpreter
(instruction_set: Union[pyshgp.push.instruction_set.InstructionSet, str] = 'core', config: pyshgp.push.interpreter.PushInterpreterConfig = None, verbosity_config: pyshgp.monitoring.VerbosityConfig = 'default')[source]¶ Bases:
object
An interpreter capable of running Push programs.
Parameters: - instruction_set (Union[InstructionSet, str], optional) – The InstructionSet to use for executing programs. Default is “core” which instansiates an InstructionSet using all the core instructions.
- config (PushInterpreterConfig, optional) – A PushInterpreterConfig specifying limits and early termination conditions. Default is None, which creates a config will all default values.
- verbosity_config (VerbosityConfig, optional) – A VerbosityConfig controling what is logged during the execution of the program. Default is no verbosity.
-
instruction_set
¶ The InstructionSet to use for executing programs.
Type: InstructionSet
-
config
¶ A PushInterpreterConfig specifying limits and early termination conditions.
Type: PushInterpreterConfig
-
verbosity_config
¶ A VerbosityConfig controling what is logged during the execution of the program. Default is no verbosity.
Type: VerbosityConfig, optional
-
state
¶ The current PushState. Contains one stack for each PushType utilized mentioned by the instructions in the instruction set.
Type: PushState
-
status
¶ A string denoting if the Interpreter has enountered a situation where non-standard termination was required.
Type: PushInterpreterStatus
-
evaluate_atom
(atom: pyshgp.push.atoms.Atom)[source]¶ Evaluate an Atom.
Parameters: atom (Atom) – The Atom (Literal, Instruction, JitInstructionRef, or CodeBlock) to evaluate against the current PushState.
-
run
(program: pyshgp.push.atoms.CodeBlock, inputs: Sequence[T_co], output_types: Sequence[str])[source]¶ Run a Push program given some inputs and desired output PushTypes.
- The general flow of this method is:
- Create a new push state
- Load the program and inputs.
- If the exec stack is empty, return the outputs.
- Else, pop the exec stack and process the atom.
- Return to step 3.
Parameters: - program – Program to run.
- inputs – A sequence of values to use as inputs to the push program.
- output_types – A secence of values that denote the Pushtypes of the expected outputs of the push program.
Returns: A sequence of values pulled from the final push state. May contain pyshgp.utils.Token.no_stack_item if needed stacks are empty.
Return type: Sequence
-
class
pyshgp.push.interpreter.
PushInterpreterConfig
(*, atom_limit=500, growth_cap=500, runtime_limit=20000000000.0, reset_on_run=True)[source]¶ Bases:
object
Define a configuration for PushInterpreter.
Parameters: - atom_limit (int, optional) – Max number of atoms to process before terminating the execution of a given program. Default is 500
- growth_cap (int, optional) – Max number of elements that can be added to a PushState at any given step of program execution. If exceeded, program terminates. Default is 500.
- runtime_limit (int, optional) – Max number of milliseconds to run a push program before forcing termination. Default is 2e10.
- reset_on_run (bool, optional) – If True, interpreter’s state and status are reset every time a program is run. Default is True.
-
atom_limit
¶ Max number of atoms to process before terminating the execution of a given program. Default is 500
Type: int
-
growth_cap
¶ Max number of elements that can be added to a PushState at any given step of program execution. If exceeded, program terminates. Default is 500.
Type: int
-
runtime_limit
¶ Max number of milliseconds to run a push program before forcing termination. Default is 2e10.
Type: int
-
reset_on_run
¶ If True, interpreter’s state and status are reset every time a program is run. Default is True.
Type: bool
pyshgp.push.stack module¶
The stack
module defines the PushStack
class.
A PushStack is used to hold values of a certain PushType in a PushState object.
-
class
pyshgp.push.stack.
PushStack
(push_type: pyshgp.push.types.PushType, values: Optional[Sequence[T_co]] = None)[source]¶ Bases:
list
Stack that holds elements of a sinlge PushType.
Parameters: - push_type (PushType) – The PushType all items of the stack should conform to.
- values (Sequence, optional) – A collection of values to push onto the stack. Values will be pushed in order resulting in the first item being at the bottom of the stack and the last item being on top.
-
insert
(position: int, value)[source]¶ Insert value at position in stack.
Parameters: - position (int) – Position in stack to get item.
- value – Value to insert into stack.
-
nth
(position: int)[source]¶ Return the element at a given position.
If stack is empty, returns None. If
position < 0
orposition > len(self)
returns ano_stack_item
token.Parameters: position (int) – Position in stack to get item. Returns: Return type: Element at positon
in stack.
-
pop
(index: Optional[int] = None)[source]¶ Pop the top item off the stack, or pop the item at some index.
Parameters: index – Index to pop from the stack. Returns: Return type: Element at index
in stack.
-
push
(value)[source]¶ Pushes a value to the top of the stack.
A type safe alias for append which makes the definition of push instructions more clear.
Parameters: value – Value to push onto stack.
-
push_type
-
set_nth
(position: int, value)[source]¶ Overwrite the item in the nth position of the stack with the new value.
Parameters: - position (int) – Position in stack to get item.
- value – Value to insert into stack.
pyshgp.push.state module¶
The state module is define the PushState class.
A PushState object holds the PushStacks, stdout string, and collection of input values. The PushState is what controls the setup of all stacks before program manipulation, and the producing of outputs after program execution.
-
class
pyshgp.push.state.
PushState
(type_library: pyshgp.push.type_library.PushTypeLibrary)[source]¶ Bases:
dict
A collection of PushStacks used during push program execution.
-
classmethod
from_dict
(d, type_library: pyshgp.push.type_library.PushTypeLibrary)[source]¶ Set the state to match the given dictionary.
Warning
This is written to be used in
pyshgp
tests, NOT as part of push program execution or evolution. There are no checks to confirm that thed
can be converted to a valid Push state.Parameters: d (dict) – Dict that is converted into a Push state.
-
inputs
¶
-
load_inputs
(inputs)[source]¶ Load a list of input values onto the PushState inputs.
Parameters: inputs (list) – List of input values.
-
load_program
(program: pyshgp.push.atoms.CodeBlock)[source]¶ Push the given CodeBlock to the execution stack.
-
observe_stacks
(types: Sequence[str]) → list[source]¶ Return a list of output values based on the given types indicated.
Items are take from the tops of each stack. If multiple occurences of the same type are in
output_types
, the returned values are taken from progressively deeper in that stack. Does not pop the values off the stacks.Parameters: types (list) – List of strings denoting the push types of the returned values.
-
pop_from_stacks
(types: Sequence[str]) → Union[Sequence[T_co], pyshgp.utils.Token][source]¶ Pop the top items for each value_type. Return a vector of the values popped from each stack.
-
pretty_print
(print_or_log_func=<built-in function print>)[source]¶ Print the state of all stacks in the PushState.
-
push_to_stacks
(values: list, types: Sequence[str])[source]¶ Check that all values can be coerced into their expected PushType. Push them onto the correct stack.
-
stdout
¶
-
type_library
¶
-
untyped
¶
-
classmethod
pyshgp.push.type_library module¶
A PushTypeLibrary describes the PushTypes which a given instance of PushGP will support.
-
class
pyshgp.push.type_library.
PushTypeLibrary
(register_core: bool = True, *args)[source]¶ Bases:
dict
A collection of PushTypes which can support a corresponding PushStack.
Parameters: - register_core (bool, optional) – If True, all core types will be registered. Default is True.
- *args – A collection of PushTypes to register.
-
register_core
[source]¶ If True, all core types will be registered. Default is True.
Type: bool, optional
-
*args
A collection of PushTypes to register.
-
create_and_register
(name: str, underlying_types: Tuple[type], coercion_func: Optional[Callable[[Any], Any]] = None, force=False)[source]¶ Create a PushType and register it into the library.
Parameters: - name (str) – A name for the type. Used when referencing the PushType in Instruction definitions and will be the key in the PushState for the corresponding PushStack.
- underlying (Tuple[type]) – A tuple of python types that correspond to the underlying native types which the PushType is representing.
- coercion_func (Callable[[Any], Any], optional) – A function which takes a single argument and returns argument coerced
into the PushTypes canonical type (the first type in
underlying
). If None, the constructor of the canonical type is used. Default is None. - force (bool) – If True, will register the type even if it will overwrite an existing reserved stack typed (eg. exec, stdout, untyped). Default is False. It is not reccomended this argument be changed unless you have a very good reason to do so.
Returns: A reference to the PushTypeLibrary.
Return type:
-
push_type_for_type
(typ: type, error_on_not_found: bool = False) → Optional[pyshgp.push.types.PushType][source]¶ Return the PushType of the given python (or numpy) type.
Parameters: - typ (type) – Any type to try and find the corresponding PushType.
- error_on_not_found (bool, optional) – If True, will raise error if no PushType found. Default is False.
Returns: The corresponding PushType of the given type. If no corresponding type, returns None.
Return type: Optional[PushType]
-
push_type_of
(thing: Any, error_on_not_found: bool = False) → Optional[pyshgp.push.types.PushType][source]¶ Return the PushType of the given thing.
Parameters: - thing (Any) – Any value to try and find the corresponding PushType.
- error_on_not_found (bool, optional) – If True, will raise error if no PushType found. Default is False.
Returns: The corresponding PushType of the thing. If no corresponding type, returns None.
Return type: Optional[PushType]
-
register
(push_type: pyshgp.push.types.PushType, force=False)[source]¶ Register a PushType object.
Parameters: push_type – PushType to register. Returns: A reference to the PushTypeLibrary. Return type: PushTypeLibrary
-
register_core
()[source] Register all core PushTypes defined in pyshgp.
Returns: A reference to the PushTypeLibrary. Return type: PushTypeLibrary
-
register_list
(list_of_push_types: Sequence[pyshgp.push.types.PushType])[source]¶ Register a list of PushType ojbects.
Parameters: list_of_push_types – List of Instruction objects to register. Returns: A reference to the PushTypeLibrary. Return type: PushTypeLibrary
-
supported_stacks
() → Set[str][source]¶ All stack names which the PushTypeLibrary can support.
Returns: A set of stacks names which the type library can support. Return type: set[str]
-
unregister
(push_type_name: str)[source]¶ Unregister a push type by name.
Parameters: push_type_name – The name of the push type to unregister. Returns: A reference to the PushTypeLibrary. Return type: PushTypeLibrary
-
pyshgp.push.type_library.
infer_literal
(val: Any, type_library: pyshgp.push.type_library.PushTypeLibrary) → pyshgp.push.atoms.Literal[source]¶ Make a literal by infering the PushType of the value.
Parameters: - val (Any) – Any value to try and make a Literal out of.
- type_library (PushTypeLibrary) – The library of PushTypes which a Literal can be made of.
Returns: The Literal object which holds the value and the corresponding PushType.
Return type:
pyshgp.push.types module¶
The types
module contains the core PushTypes and functions to reference them.
A PushType simply is a named collection of Python types. A PushType can be used to determine if multiple items should be considered the same type during Push program execution.
-
class
pyshgp.push.types.
Char
(char)[source]¶ Bases:
str
Holds a string of length 1.
Used to distinguish between string and char literals in Push program interpretation.
-
char
¶ String of length 1.
Type: str
-
-
class
pyshgp.push.types.
PushType
(name: str, underlying: Tuple[type], coercion_func: Optional[Callable[[Any], Any]] = None)[source]¶ Bases:
object
Type information for values used by Push programs.
Parameters: - name (str) – A name for the type. Used when referencing the PushType in Instruction definitions and will be the key in the PushState for the corresponding PushStack.
- underlying (Tuple[type]) – A tuple of python (or numpy) types that correspond to the underlying native types which the PushType is representing.
- coercion_func (Callable[[Any], Any], optional) – A function which takes a single argument and returns argument coerced
into the PushTypes canonical type (the first type in
underlying
). If None, the constructor of the canonical type is used. Default is None.
-
name
¶ A name for the type. Used when referencing the PushType in Instruction definitions and will be the key in the PushState for the corresponding PushStack.
Type: str
-
underlying
¶ A tuple of python (or numpy) types that correspond to the underlying native types which the PushType is representing.
Type: Tuple[type]
-
coercion_func
¶ A function which takes a single argument and returns argument coerced into the PushTypes canonical type (the first type in
underlying
). If None, the constructor of the canonical type is used. Default is None.Type: Callable[[Any], Any], optional
Module contents¶
pyshgp.push.


{% load static %}
The Xbox1 stands as microsofts greatest console to date.You can rent a console along with headsets, additional controllers, and a xbox kinect. We have the early release models as well as the slim models. Consoles rented will be randomly assigned to customers.
Accessories include extra name brand controllers along with headsets and exclusive for each conosle.The Xbox1 has the kinect available for rent while the ps4 has the powerful Virtual Reality set to go along with it.
The store was founded in early 2017 with a purpose to bring consoles for rent at an affordable price.
Consoles and accessories are rented sepratly. Prices vary depinding on console and specific accessory needed.


Meowth gift now available to all players of Pokemon Sword & Shield
by My Nintendo News AdminPokemon Sword & Shield players will be pleased to know they can now get hold of Meowth as a gift in the newly released Pokemon game on Nintendo Switch. If you claim him you will get a Meowth (Level 5) capable of Gigantamaxing and one who has the moves Fake Out, Growl, Slash, and Pay Day. To claim your Meowth all you need to do is simply go to Mystery Gift and you’ll be granted one after you’ve finished the opening steps within the game.


begin
Syntax
A beginStatement is:
| |
begin |
| |
|
statementsAndDeclarations |
| |
end |
Description
A begin statement limits the scope of declarations made within it to the confines of the begin/end block. In Turing, begin is rarely used, because declarations can appear wherever statements can appear, and because every structured statement such as if ends with an explicit end.
Example
begin
var bigArray : array 1 .. 2000 of real
bigArray will exist only inside this begin statement
end
Details
In Pascal programs, begin statements are quite common because they are required for grouping two or more statements, for example, to group the statements that follow then. This is not necessary in Turing as where ever you can write a single statement, you can also write several statements.


DARK-mode.css
We-demy is a website where you can learn anything remotely.
We offer you a fully equipped courses to get you started.
This is Maths Class. Here you can study maths. You can solve the standard problems and become the expert in maths.
This is Physics Class. Here you can study physics. You can solve the standard problems and become the expert in physics.
This is Biology Class. Here you can study biology. You can study biology here and become the expert in biology.
This is History Class. Here you can study history. You can study history here and become the expert in history.
This is Meteorology Class. Here you can study meteorology. You can study eteorology here and become the expert in eteorology.
This is Astrology Class. Here you can study astrology. You can study strology here and become the expert in astrology.
This is Geology Class. Here you can study geology. You can study geology here and become the expert in geology.


Since 2009, I have built and published over 25 of my own apps to the Apple App Store. The following list is a small sample of some of the apps I have built. Since the beginning of 2021; I have targeted the iOS 14 WidgetKit niche with 5 simple apps currently live on the App Store. As of July 2021, these 5 apps have had over 50k downloads.


Writer’s secret? Shut the door and no interruptions till you’re done
by Killugudi JayaramanYour piece ‘Day in the life of a 24-hour global news factory’ revived memories of my only visit to the Nature office (see go.nature.com/2k9scd1). The occasion was in the early 1980s, when John Maddox was in his second term as editor-in-chief and he invited me to report news stories from India for the journal. He wrote many himself, one of which included an interview with Indira Gandhi, the country’s prime minister at the time (see Nature 308, 582; 1984).
When I met the great man again, he was in hospital being treated for a leg injury. He passed his days there avidly reading, writing and editing as usual. I enquired after his secret of being able to write such insightful editorials on a host of topics — ranging from physics to philosophy — week after week. His reply was that he always firmly shut his office door, allowing no phone calls or other interruptions until he had completed his next editorial.
Nature 575, 443 (2019)