text:
\chapter{AST}
This section describes each construct of the JavaScript language
in both the BNF notation and its corresponding implementation.
The implementation of AST nodes is available at:
\begin{verbatim}
$SAFE_HOME/src/main/scala/kr/ac/kaist/safe/nodes/
           ast/
\end{verbatim}
\small
\[
\begin{array}{llll}
\pgm & ::=  & \fd^*\ \vd^*\ \stmt^* \\
&& \mtt{Program(body:~TopLevel)}\\
    &&\mtt{TopLevel(fds:~List[FunDecl], vds:~List[VarDecl],}\\
&&\mtt{\phantom{TopLevel(}stmts:~List[SourceElements])}\\\\

\fd &::=& {\tt function} \ f \verb+(+(x\verb+,+)^*\verb+)+ \ \verb+{+\fd^*\ \vd^*\ \stmt^*\verb+}+\\
&& \mtt{FunDecl(ftn:~Functional, strict:~Boolean)}\\
&& \mtt{Functional(fds:~List[FunDecl],}\\
&&\mtt{\phantom{Functional(}vds:~List[VarDecl],}\\
&&\mtt{\phantom{Functional(}stmts:~SourceElements, name:~Id,}\\
&&\mtt{\phantom{Functional(}params:~List[Id], body:~String)}\\\\

\vd &::=& x \ ({\tt =} \ \expr)^? \\
&& \mtt{VarDecl(name:~Id, expr:~Option[Expr],}\\
&& \mtt{\phantom{VarDecl(}strict:~Boolean)}\\\\

\stmt &::=& \verb+{+\stmt^*\verb+}+ \\
&& \mtt{ABlock(stmts:~List[Stmt], internal:~Boolean)}\\
& \mid & {\tt var} \ \vd(\verb+,+ \vd)^* \verb+;+ \\
&& \mtt{VarStmt(vds:~List[VarDecl])}\\
& \mid & \verb+;+ \\
&& \mtt{EmptyStmt()}\\
& \mid & \expr \verb+;+ \\
&& \mtt{ExprStmt(expr:~Expr, internal:~Boolean)}\\
& \mid & {\tt if} \ \verb+(+\expr\verb+)+ \ \stmt \ ({\tt else} \ \stmt)^?\\
&& \mtt{If(cond:~Expr, trueBranch:~Stmt,}\\
&&\mtt{\phantom{If(}falseBranch:~Option[Stmt])}\\
& \mid &  {\tt switch} \ \verb+(+\expr\verb+)+ \ \verb+{+\cc^* \ ({\tt default} \verb+:+ \stmt^{*})^? \ \cc^* \verb+}+\\
&& \mtt{Switch(cond:~Expr, frontCases:~List[Case],}\\
&&\mtt{\phantom{Switch(}defopt:~Option[List[Stmt]],}\\
&&\mtt{\phantom{Switch(}backCases:~List[Case])}\\
& \mid & {\tt do} \ \stmt \ {\tt while} \ \verb+(+\expr\verb+)+ \verb+;+ \\
&& \mtt{DoWhile(body:~Stmt, cond:~Expr)}\\
  &\mid& {\tt while} \ \verb+(+\expr\verb+)+ \ \stmt \\
&& \mtt{While(cond:~Expr, body:~Stmt)}\\
\end{array}
\]

\[
\begin{array}{llll}
  &\mid& {\tt for} \ \verb+(+\expr^?\verb+;+ \expr^?\verb+;+ \expr^? \verb+)+ \ \stmt\\
&& \mtt{For(init:~Option[Expr], cond:~Option[Expr],}\\
&&\mtt{\phantom{For(}action:~Option[Expr], body:~Stmt)}\\
  &\mid& {\tt for} \ \verb+(+ \lhs \ {\tt in} \ \expr \verb+)+ \ \stmt \\
&&\mtt{ForIn(lhs:~LHS, expr:~Expr, body:~Stmt)}\\
  &\mid& {\tt for} \ \verb+(+{\tt var} \ \vd(\verb+,+ \vd)^*\verb+;+ \expr^?\verb+;+ \expr^?\verb+)+ \ \stmt\\
&& \mtt{ForVar(vars:~List[VarDecl], cond:~Option[Expr],}\\
&&\mtt{\phantom{ForVar(}action:~Option[Expr], body:~Stmt)}\\
&\mid& {\tt for} \ \verb+(+{\tt var} \ \vd \ {\tt in} \ \expr \verb+)+ \ \stmt \\
&& \mtt{ForVarIn(vd:~VarDecl, expr:~Expr, body:~Stmt)}\\
& \mid & {\tt continue} \  \myid^{?} \verb+;+ \\
&& \mtt{Continue(target:~Option[Label])}\\
& \mid & {\tt break} \  \myid^{?} \verb+;+ \\
&& \mtt{Break(target:~Option[Label])}\\
& \mid & {\tt return} \ \expr^? \verb+;+ \\
&& \mtt{Return(expr:~Option[Expr])}\\
& \mid & {\tt with} \ \verb+(+\expr\verb+)+ \ \stmt \\
&& \mtt{With(expr:~Expr, stmt:~Stmt)}\\
& \mid & l \; \verb+:+ \; \stmt \\
&& \mtt{LabelStmt(label:~Label, stmt:~Stmt)}\\
& \mid & {\tt throw} \ \expr \verb+;+ \\
&& \mtt{Throw(expr:~Expr)}\\

& \mid &
{\tt try} \verb+{+\stmt^*\verb+}+ ({\tt catch} \verb+(+\myid\verb+)+ \verb+{+\stmt^*\verb+}+)^? ({\tt finally} \verb+{+\stmt^*\verb+}+)^?\\
&& \mtt{Try(body:~List[Stmt], catchBlock:~Option[Catch],}\\
&& \mtt{\phantom{Try(}fin:~Option[List[Stmt]])}\\
&& \mtt{Catch(id:~Id, body:~List[Stmt])}\\
& \mid & {\tt debugger} \verb+;+ \\
&& \mtt{Debugger()}\\\\

\cc &::=& {\tt case} \ \expr \; \verb+:+ \; \stmt^{*} \\
&& \mtt{Case(cond:~Expr, body:~List[Stmt])}\\\\

\expr &::=& \expr\verb+,+ \ \expr \\
&& \mtt{ExprList(exprs:~List[Expr])}\\
  &\mid& \expr \ \verb+?+ \ \expr \ \verb+:+ \ \expr \\
&& \mtt{Cond(cond:~Expr, trueBranch:~Expr,}\\
&& \mtt{\phantom{Cond(}falseBranch:~Expr)}\\
  &\mid& \expr \ \inop \ \expr \\
&& \mtt{InfixOpApp(left:~Expr, op:~Op, right:~Expr)}\\
  &\mid& \preop \ \expr \\
&& \mtt{PrefixOpApp(op:~Op, right:~Expr)}\\
  &\mid& \lhs \ \postop \\
&& \mtt{UnaryAssignOpApp(lhs:~LHS, op:~Op)}\\
  &\mid& \lhs \ \aop \ \expr \\
&& \mtt{AssignOpApp(lhs:~LHS, op:~Op, right:~Expr)}\\
  &\mid& \lhs \\
&& \mtt{LHS()}\\\\
\lhs &::=& \lit \\
&& \mtt{Literal()}\\
 &\mid& \myid \\
&& \mtt{VarRef(id:~Id)}\\
 &\mid& \verb+[+ (\expr^?\verb+,+)^* \ \verb+]+ \\
&& \mtt{ArrayExpr(elements:~List[Option[Expr]])}\\
 &\mid& \verb+{+ (\member\verb+,+)^* \verb+}+ \\
&& \mtt{ObjectExpr(members:~List[Member]}\\
 &\mid& \verb+(+ \expr \verb+)+ \\
&& \mtt{Parenthesized(expr:~Expr)}\\
\end{array}
\]

\[
\begin{array}{llll}
 & \mid & {\tt function} \ \myid^?  \verb+(+(\myid\verb+,+)^*\verb+)+ \ \verb+{+\fd^*\ \vd^*\ \stmt^*\verb+}+ \\
&&\mtt{FunExpr(ftn:~Functional)}\\
 &\mid& \lhs \verb+[+ \expr \verb+]+ \\
&& \mtt{Bracket(obj:~LHS, index:~Expr)}\\
 &\mid& \lhs \verb+.+ \myid \\
&& \mtt{Dot(obj:~LHS, member:~Id)}\\
 &\mid& {\tt new} \ \lhs \\
&& \mtt{New(lhs:~LHS)}\\
 &\mid& \lhs \verb+(+ (\expr\verb+,+)^* \verb+)+ \\
&& \mtt{FunApp(fun:~LHS, args:~List[Expr])} \\ \\
\lit &::=& {\tt this} \\
&& \mtt{This()}\\
 &\mid& {\tt null} \\
&& \mtt{Null()}\\
 &\mid& {\tt true} \\
&& \mtt{Bool(bool:~Boolean)}\\
 &\mid& {\tt false} \\
&& \mtt{Bool(bool:~Boolean)}\\
 &\mid& \num \\
&& \mtt{DoubleLiteral(text:~String, num:~Double)}\\
&&\mtt{IntLiteral(intVal:~BigInteger, radix:~Integer)}\\
 &\mid& \str \\
&& \mtt{StringLiteral(quote:~String, escaped:~String)}\\
 &\mid& \reg \\
&& \mtt{RegularExpression(body:~String, flag:~String)}\\ \\

\member &::=& \prop \ \verb+:+ \ \expr \\
&& \mtt{Field(prop:~Property, expr:~Expr)}\\
 &\mid& {\tt get}\ \prop \verb+() {+ \fd^*\ \vd^*\ \stmt^* \verb+}+ \\
&& \mtt{GetProp(prop:~Property, ftn:~Functional)}\\
 &\mid& {\tt set}\ \prop \verb+(+ \myid \verb+) {+ \fd^*\ \vd^*\ \stmt^* \verb+}+\\
&& \mtt{SetProp(prop:~Property, ftn:~Functional)}\\ \\

\prop &::= & \myid \\
&& \mtt{PropId(id:~Id)}\\
 &\mid& \str \\
&& \mtt{PropStr(str:~String)}\\
 &\mid& \num \\
&& \mtt{PropNum(num:~NumberLiteral)}\\
\end{array}
\]

\[
\begin{array}{l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l@{\;}l}
\aop &::=&
\verb+=+ & \mid &
\verb+*=+ & \mid &
\verb+/=+ & \mid &
\verb+%=+ & \mid &
\verb!+=! & \mid &
\verb+-=+ & \mid &
\verb+[[=+ & \mid &
\verb+>>=+ & \mid &
\verb+>>>=+ & \mid &
\verb+&=+ & \mid &
\verb+^=+ & \mid &
\verb+|=+
\\

\inop &::=& \verb+&&+ & \mid & \verb+||+ & \mid & \verb+|+ & \mid & \verb+&+ & \mid & \verb+^+ & \mid & \verb+[[+ & \mid & \verb+>>+ & \mid & \verb+>>>+
 & \mid & \verb!+! & \mid & \verb+-+ & \mid & \verb+*+ & \mid & \verb+/+ \\
 & \mid & \verb+%+
 &\mid& \verb+==+ & \mid & \verb+!=+ & \mid & \verb+===+ & \mid & \verb+!==+ & \mid & \verb+[+ & \mid & \verb+>+ & \mid & \verb+[=+
 & \mid & \verb+>=+ \\
 & \mid &
\lefteqn{
 {\tt instanceof} \ \mid \ {\tt in} }\\

\preop &::=& \verb!++! & \mid & \verb+--+ & \mid & \verb+~+ & \mid & \verb+!+ & \mid & \verb!+! & \mid & \verb+-+ & \mid &
\lefteqn{
 {\tt delete} \ \mid \ {\tt void} \ \mid \ {\tt typeof} }\\

\postop &::=& \verb!++! & \mid & \verb+--+\\[1em]

\end{array}
\]

Note that after the \verb!Hoister! transformation of the \verb!astRewriter! phase,
ASTs should have the following invariants:
\begin{itemize}
\item The {\tt expr} field of {\tt VarDecl} should be {\tt None}.
\item {\tt VarStmt}, {\tt ForVar}, and {\tt ForVarIn} should be removed.
\item {\tt StmtUnit} is an internally generated statement unit.
\end{itemize}


text:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CS622: Theory of Formal Languages
% Copyright 2014 Pejman Ghorbanzade <pejman@ghorbanzade.com>
% Creative Commons Attribution-ShareAlike 4.0 International License
% More info: https://github.com/ghorbanzade/beacon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section*{Question 1}

Let $L, K$ be two regular languages on an alphabet $A$.
Prove that the set of words $t \in A^*$ that can be written as $$ t = xy^R = u^R z $$ for some $x,u \in L$ and $y, z \in K$ is a regular language.

\subsection*{Solution}

To prove set of words $t \in A^*$ is a regular language, we take advantage of the fact that a language is regular, if and only if it can be recognized with a transition system. The objective would now be to construct a transition system $\mathcal{T}$ that recognizes the language.
Such a transition system is depicted in Figure \ref{fig:DR1}.

\begin{figure}\centering
	\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,semithick]
		\tikzstyle{final}=[circle,thick,draw=black,fill=gray!20,text=black]
		\node[state,initial] (0) {$q_0$};
		\node[state] (1) [below left of=0] {$q_1$};
		\node[state,final] (2) [below right of=0] {$q_2$};
		\node[state,accepting] (3) [below of=1] {$q_3$};
		\node[state,final,accepting] (4) [below of=2] {$q_4$};
		\node[draw=black, fit= (1) (2), inner sep=0.5cm, dotted] {};
		\node[draw=black, fit= (3) (4), inner sep=0.5cm, dotted] {};
		\node[draw=black, fit= (0)(1)(2)(3)(4), inner sep=1cm, dashed] {};
		\node[yshift=1.25cm, xshift=-1.25cm, black] at (1) {$\mathcal{L}$};
		\node[yshift=1.25cm, xshift=-1.25cm, black] at (3) {$\mathcal{K}$};
		\node[yshift=1.25cm, xshift=-4cm, black] at (0) {$\mathcal{T}$};
		\path
			(0) edge [bend left] node {$\lambda$} (2)
				edge [bend right]node {$\lambda$} (1)
			(1) edge [bend right=0]node {$\lambda$} (3)
			(2)	edge [bend left=0] node {$\lambda$} (4);
		\path[dashed]
			(1) edge [bend left=20] node {x}	(2)
				edge [bend right=20]node {u}	(2)
			(3) edge [bend left=20] node {y}	(4)
				edge [bend right=20]node {z}	(4);
	\end{tikzpicture}
	\caption{A schematic representation of transition system $\mathcal{T}$}
	\label{fig:DR1}
\end{figure}

For simplicity of representation, only initial and set of final states of transition systems $\mathcal{L}$ and $\mathcal{K}$ are shown, where $\mathcal{L}(m)=L$ and $\mathcal{K}(m)=K$.
States $q_1$ and $q_3$ respectively represent initial states of $\mathcal{L}$ and $\mathcal{K}$.
Without loss of generality, it is assumed that there is only one final state for $\mathcal{L}$ and $\mathcal{K}$.
These final states are colored in gray.
As words $x,u \in L$ are accepted by the language, inputs $x,u$ are shown with dashed lines, only to suggest there are paths $x$ and $u$ from initial state $q_1$ to set of final states $q_2$.
Similarly $y,z \in K$ are shown with dashed lines.

As the new transition system $\mathcal{T}$ must accept inputs of the form $t = xy^R$ and $t = u^Rz$, spontaneous transitions $\lambda$ are introduced between initial states and final states of $\mathcal{L}$ and $\mathcal{K}$.
We can now start from $q_1$, apply $x$, $\lambda$ and $y^R$ and end up in $q_3$.
We can also start from $q_2$, apply $u^R$,$\lambda$ and $z$ and end up in $q_4$.
States $q_3$ and $q_4$ are therefore assigned as final states of $\mathcal{T}$ and are shown with double-circles.
As we cannot have multiple initial states, a new state $q_0$ is introduced to the system and is assigned the initial state.

We can now argue that the set of words $t \in A^*$ where $t = xy^R = u^Rz$ can all be accepted by the transition system $\mathcal{T}$.
As we constructed a system that recognizes the language, it is proven that the language is regular.

ext: tex

max_stars_repo_name: ghorbanzade/beacon

max_issues_repo_name: ghorbanzade/beacon

max_forks_repo_name: ghorbanzade/beacon


text:
This appendix describes the functions that are provided in the phaml\_example module and that must be maintained in any new modules.  The subroutines exist within the example module rather than the support module so that they can be modified or tweaked based on the specific problem.  PHAML provides many options to all function calls and this method allows the options to be different between modules if desired without affecting another module.

These are wrappers to ease the use of PHAML and to setup all initial conditions and make sure everything is properly handled with PHAML and the other modules needed.  Please see the guide for the native PHAML functions. \citep{phamldoc}

\subsection{Main Module}\label{sec:libfuncmain}

\begin{itemize}
\item \textbf{phaml\_init} - This subroutine simply sets the needed variables for the usermod module to work.  It does not instantiate the phaml\_solution.
\item \textbf{phaml\_setup} - If doing a non-linear PDE problem then this initializes the phaml\_solution, creates the mesh, and sets the initial conditions.  To solve phaml\_nonlin\_evolve must be called.
\item \textbf{phaml\_evolve} - This is a single pass solve where the function assumes the problem is linear.  It creates the mesh, initializes PHAML, solves the problem, retrieves the solution, then closes PHAML.
\item \textbf{phaml\_nonlin\_evolve} - This subroutine assumes phaml\_setup has already been called and that the solution is incremental.  It copies the old solution then does another iteration and returns.
\item \textbf{phaml\_getsolution} - Given the phaml\_solution variable it simply returns the current solution at the node points of the GLIMMER-CISM model grid.
\item \textbf{phaml\_close} - This destroys the phaml session variable as well as deallocates the variables used in usermod.
\end{itemize}

\subsection{PHAML Callbacks}\label{sec:libphamlcall}

This subsection lists the subroutines and functions that PHAML relies on and must be present in order for it to define the PDE and to find a solution.  Given the type of solution desired, many of them don't need to be used, but they must all still exist even if returning zero.  Please refer to the manual for more detailed descriptions, special circumstances, arguments, and examples.  \citep{phamldoc}

\begin{itemize}
\item \textbf{pdecoefs} - This subroutine returns the coefficient and right hand side of the PDE at the point (x,y).
\item \textbf{bconds} - This subroutine returns the boundary conditions at the point (x,y).
\item \textbf{iconds} - This routine returns the initial condition for a time dependent problem at the point (x,y).
\item \textbf{trues} - This is the true solution of the differential equation at point (x,y), if known.
\item \textbf{truexs} - This is the x derivative of the true solution of the differential equation at point (x,y), if known.
\item \textbf{trueys} - This is the y derivative of the true solution of the differential equation at point (x,y), if known.
\item \textbf{boundary\_point} -  This routine defines the boundary of the domain at the point (x,y) if no mesh was provided.
\item \textbf{boundary\_npiece} - This routine gives the number of pieces in the boundary definition if no mesh was provided.
\item \textbf{boundary\_param} - This routine gives the range of parameter values for each piece of the boundary if no mesh was provided.
\item \textbf{phaml\_integral\_kernel} - This is the identity function that PHAML requires and shouldn't need any modification.
\item \textbf{regularity} - Provides the \emph{a priori} knowledge about the singular nature of the solution if applicable.
\item \textbf{update\_usermod} - This routine updates the module variables by sending them from the master to the slave processes.  This function is very important for the simulation to work correctly, and the data formatting is addressed in more detail in section \ref{sec:libfuncuser}.

\end{itemize}
%\begin{table}[ht]
%\caption{PHAML PDE Callback Functions \cite{phamldoc}}
%\centering
%\begin{center}
%    \begin{tabular}{ | c | c |}
%    \hline
%    \multicolumn{2}{|c|}{PHAML PDE Functions}\\
%    \hline
%    Function Name & Description \\ \hline
%    pdecoefs & This subroutine returns the coefficient and right \\
%    &   hand side of the PDE at the point (x,y). \\ \hline
%    bconds & This subroutine returns the boundary conditions at the\\
%    &   point (x,y). \\ \hline
%    iconds & This routine returns the initial condition for a time\\
%    &   dependent problem at the point (x,y). \\ \hline
%    trues & This is the true solution of the differential equation\\
%    &   at point (x,y), if known.\\ \hline
%    truexs & This is the x derivative of the true solution of the \\
%    &   differential equation at point (x,y), if known. \\ \hline
%    trueys & This is the y derivative of the true solution of the \\
%    &   differential equation at point (x,y), if known. \\ \hline
%    boundary\_point &  This routine defines the boundary of the domain \\
%    &   at the point (x,y) if no mesh was provided. \\ \hline
%    boundary\_npiece & This routine gives the number of pieces in the boundary\\
%    &   definition if no mesh was provided. \\ \hline
%    boundary\_param & This routine gives the range of parameter values for\\
%    &   each piece of the boundary if no mesh was provided. \\ \hline
%    \end{tabular}
%\end{center}
%\end{table}

\subsection{Support Module}\label{sec:libfuncsupp}

These subroutines are independent of PHAML and are simply support functions needed by the various PHAML modules that can be created.  There is a possibility that some of them may need to be modified depending on a particular simulation need, but in general should be applicable to most situations.

\begin{itemize}
\item \textbf{is\_ice\_edge} - This function uses the mask to determine if a node is the last node on the glacier to have ice.  It does this by checking all four surrounding nodes to make sure at least one of them doesn't have ice.
\item \textbf{get\_bmark} - This function returns the boundary marker required in the .poly file for edges.  Currently it uses the `mask' value, but can be changed depending on other needs.
\item \textbf{make\_ice\_poly\_file} - This subroutine generates the mesh file that PHAML loads by only using nodes that have ice as decided by the mask in CISM.  It uses the get\_bmark and is\_ice\_edge subroutines.  Once it writes out the .poly file it calls Triangle in order to process it for use by PHAML.
\item \textbf{make\_full\_poly\_file} - This subroutine generates the mesh file that PHAML loads by using the full domain space.  A rectangular grid will always be output.  The function writes out the .poly file and then calls Triangle in order to process it for use by PHAML.
\end{itemize}

\subsection{Usermod Module}\label{sec:libfuncuser}

The usermod module is a set of variables and routines that are used or might be used from within the PHAML callbacks.  Any data coming from GLIMMER-CISM would need to be set in one of these variables and then could be used in a callback.  All the data must be passed on to PHAML's slaves though the function `update\_usermod' that is in the set of PHAML callbacks.  These callbacks can be tricky and are explained further in section \ref{sec:libphamlcall}.  The usermod module is addressed in chapter \ref{ch:softintegration} section \ref{sec:ch4usermod}.

\subsubsection{The functions}

\begin{itemize}
\item \textbf{user\_init} - This function sets up the initial data for the usermod module.
\item \textbf{user\_close} - This function serves to call any closing subroutines or deallocate any user data that was initialized.
\item \textbf{array\_init} - Once the slaves have the data from user\_init, the array variables can be allocated and sent as well.  This function should be called from within update\_usermod.
\item \textbf{array\_close} - This is to deallocate the arrays used in the usermod function which had to be dynamically allocated.
\item \textbf{concat\_arrays} - Since the usermod requires all data be passed in one array it might be necessary to pass more than one, and it would be easy to lose track of them.  This function concatenates them together in a consistent fashion.
\item \textbf{split\_arrays} - This is the inverse function to concat\_arrays.  It will split an array back into the original two based on the length specified in the usermod data.
\item \textbf{reshape\_array\_to\_one} - In order to pass data to the slaves in PHAML, all data must be passed in a single dimension array.  This function takes a two dimensional array and converts it to one dimension.
\item \textbf{reshape\_array\_to\_two} - This is the inverse function to reshape\_array\_to\_one.  It takes in the single dimension array and splits it back into two dimensions based on the model `nsn' and `ewn'.
\item \textbf{get\_xyarrays} - PHAML returns the solution in one long array, so this function returns two arrays with the corresponding node locations in absolute dimensions to pass to the phaml\_evaluate function.
\item \textbf{getew} - Given an x in absolute coordinates, this divides it by the `dew' and truncates it into an integer in order to return the nearest ew coordinate for the grid.
\item \textbf{getns} - Given a y in absolute coordinates, this divides it by the `dns' and truncates it into an integer in order to return the nearest ns coordinate for the grid.
\end{itemize}

\subsubsection{The variables}

\begin{itemize}
\item \textbf{gnsn} - The number of nodes in the north/south direction of the grid.
\item \textbf{gewn} - The number of nodes in the east/west direction of the grid.
\item \textbf{gdns} - The representative distance in meters between each node in the north / south direction.
\item \textbf{gdew} - The representative distance in meters between each node in the east / west direction.
\item \textbf{num\_arrays} - The number of arrays needed to be passed via update\_usermod
\item \textbf{modnum} - The unique identifier (integer) for this module so that the correct callback functions will be used.
\end{itemize}

max_stars_repo_name: fmyuan/clm-microbe

max_issues_repo_name: fmyuan/clm-microbe

max_forks_repo_name: email-clm/CLM-Microbe


text:
\section{Literature review}

Malware is now an international word, which gained prominence following the
creation and development of the internet. There are many definitions of
malware. Malware is often defined as a short form of malicious software
containing malicious programs such as computer viruses and worms. With the
increasing sophistication of malware attacks and their potential for causing
major damage and disruption, there is an ongoing need for the development of
more advanced malware detectors\cite{Malware-tech}.

\subsection{Malware Detection: Approaches}

Malware detectors employ a variety of malware detection techniques depending on
the type of malware being targetted. In general, malware detection techniques
can be classified into two groups: the first group is heuristic-based (or
anomaly-based) detection that defines normal behaviour in order to determine
the maliciousness of the software. The second group is signature-based
detection that compares the code content to the code signature of known malware in
order to decide the maliciousness of a program under inspection. However,
current detection techniques that are based on known malware are unable to
detect a malcode unless it has been executed. Hence, not all malwares can
be detected by these two techniques alone. Therefore, it is crucial to consider how
we can extend the available detection tools by designing and developing a
detection system capable of detecting other unknown
malwares\cite{Malware-tech}.

In recent years, machine learning methods were introduced to the malware
detection systems to extend the effectiveness of heuristic-based methods. The
classification algorithm is one of the standard methods in machine learning
that could solve the problem of detecting unknown malwares\cite{Machin-learn}.
The idea of classification algorithm is based on pattern matching. The
classifier contains a set of learnt patterns and decides the maliciousness of
an unknown program by comparing to these learnt patterns. The learnt pattern set is as
a result of applying learning methods on a training set that contain instances
of both malicious and benign files. A recent study on integrating machine
learning methods with heuristic-base methods produced positive results in
detecting new malware\cite{Machin-learn}. The file representation and feature
selection methods are other machine learning techniques that greatly improve
the result of malware detection systems. The latter method is concerned with
patterns used for demonstrating executable files while the former seeks to
decrease the dimensionality of patterns that appear in the
file\cite{Machin-learn}.

Polymorphic viruses are a complex type of malware that many widely used malware
detection software will fail to detect because such malware detection software
tends to employ Heuristic-based and signature-based algorithms. Furthermore, the
drawbacks to using signature-based methods are that they are expensive and also
slow.  The recently designed system called Intelligent Malware Detection System
(IMDS) is capable of recognising both polymorphic and previously unseen
malicious executable (new) malware. The evaluation and experimental results of the IMDS illustrated its high performance compared with some anti-virus software such as McAfee virus scan. IMDS uses data mining based classification method and the architecture of the IMDS system includes three main modules; the parser,the rule generator and the malware detection part\cite{IMDS}.

One of the most commonly used formats for reading documents is PDF. Therefore,
it is likely that an attackers use PDF files for malicious purposes. Also, it
is important to note the structure of PDF documents, which is made up of a
sequence of flexible dictionary objects. This flexibility makes PDF files more
attractive for an attacker because they can host a variety of applications such
as java script and embedded files. Attackers mostly apply obfuscation
techniques to bypass intelligent detection systems. With the aid of machine
learning techniques, a new PDF detector has been designed to recognise infected
PDF documents\cite{maiorca2012pattern}.  The PDF detector contains three main
steps; a data retrieval module, a feature extractor module and the classifier.
The system adapted K-mean clustering method to collect the set of keywords for
the feature extractor module. The classifier was tested using different
classification algorithms such as Naïve Bayes and SVM, with the most accurate
and efficient algorithm being selected for the final
design\cite{maiorca2012pattern}.

The signature-based method can fail to detect the obfuscation code because the
obfuscation only has a minor effect on execution behaviour. Gao et al proposed
the semantic based malware detection algorithm to handle obfuscation in
infected documents. According to this algorithm the semantic of the program is
compared to the semantic of the malware. As a result, this proposed method
reduces the need for frequently updating the malware database; hence making it
remarkably robust\cite{Amom}.

Malware is continuing to grow and become more complex. An effective malware
detector must be capable of detecting unknown malware as well as hidden
malcode. However, malware writers analyse the techniques used in commercial
malware scanners and attempt to produce new malware that can bypass the
techniques adopted by such virus scanners. Therefore, an increase in unknown
malware is, at present, innevitable\cite{vinod2009survey}.

Another study performed on malware detection methods was called BINSPECT, which
provided a lightweight approach to identifying malicious web pages. This
approach employed supervised learning technique for its detection and
considered malware distributing techniques such as; phishing,
derived-by-download and injection\cite{eshete2012binspect}.

BINSPECT used an unknown webpage as an input and classified the web page as
either malicious or benign. Its classification relied on the features extracted
from a given web page and the web page features were defined in three
categories; features of URL, source code of webpage and social reputation
features.  For the URL features, the structure of URL (for example, number of
dots ‘.’) or the length of the URL string was analyzed. The results showed the
most malicious URL had an abnormal length. For the web page source code, an
emulated browser was used to capture the obfuscated JavaScript. Some of the
features considered in the web page sources code included the number of; lines,
links and suspicious functions. The extracted features were then used to
collect the data for the training set and learning set. The data was then
classified by applying machine-learning methods such as Logistic Regression,
SVM (Support Vector Machine) and Decision Tree\cite{eshete2012binspect}.  The
paper concludes its proposed method is very effective in detecting a malicious
webpage with an accuracy rate exceeding 97\% and that by adding the new
features to the system improved its performance significantly. However
BINSPECT lacked the ability to analyse obfuscated
JavaScript\cite{eshete2012binspect}.

max_stars_repo_name: chrissorchard/malucrawl

max_issues_repo_name: chrissorchard/malucrawl

max_forks_repo_name: chrissorchard/malucrawl


text:
\documentclass[11pt, oneside]{article}
\usepackage[margin=1in]{geometry} \geometry{letterpaper}
\usepackage{setspace}
\usepackage[font=singlespacing,labelfont=bf]{caption}
\usepackage{indentfirst}
\usepackage{float}
\usepackage{booktabs}
\usepackage{amsmath, gensymb}
\usepackage{url}

\usepackage{graphicx}
\makeatletter
\def\maxwidth{0.6\columnwidth}
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}

\title{Markdown To Report\\\vspace{0.5em}{\large A collection of scripts to generate LaTeX formatted PDFs}}
\author{Kai Wells}
\date{}

\hyphenpenalty=100000

\begin{document}

\pagenumbering{gobble}
\maketitle
\begin{table}[H]
\centering
\begin{tabular}{l}
Github Example\\
Due: April 7, 2015\\
Received: April 7, 2015\\
\end{tabular}
\end{table}
\begin{noindent}
\textbf{Normally this is a brief summary of the important results found in an experiment. This is just an example.}
\end{noindent}

\newpage
\doublespacing
\pagenumbering{arabic}

\section{Introduction}

This is a brief example of what this collection of scripts does. The metadata above is used to generate the title page of the report.

\begin{figure}[H]
\centering
\includegraphics{graph.png}
\caption{Images with captions are defined like so.}
\label{fig:labels-are-required}
\end{figure}

\begin{table}[H]
\caption{This is an example table.}
\centering
\begin{tabular}{|l|ccr|}
\hline
a & b & c & d\\
\hline
1 & 2 & 3 & 4\\
\hline
\end{tabular}
\label{table:labels-are-required-too}
\end{table}

Figure and table labels are required and must appear in [square brackets] below the object they are labeling.

\begin{equation}
E = m c^2
\label{eq:optional}
\end{equation}

Equations have to be entered in standard LaTeX format. As do \emph{italicized} and \textbf{bolded} passages. I'll work on that in the future.

Careful of typos! The makefile will hang if it encounters a LaTeX error while converting to PDF.

\end{document}

max_stars_repo_name: quells/MarkdownToReport

max_issues_repo_name: quells/MarkdownToReport

max_forks_repo_name: quells/MarkdownToReport


text:
%\subsection{Overview}\label{evalsensorExecutable_evalsensorOverview}
The \code{evalsensor} executable is used to compute information about the impact
of contamination incidents for one or more sensor network designs. The \code{evalsensor}
executable takes a sensor network design in a sensor placement file (see File Formats Section
\ref{formats_sensorPlacementFile} for more detail) and evaluates them using data from
an impact file or a list of impact files (see File Formats Section \ref{formats_impactFile}).
This executable measures the performance of each sensor network designs with respect
to the set of possible contamination scenarios.

Section \ref{solvers_solvers6} provides more information and an example application of
this executable.

\subsection{Usage}\label{evalsensorExecutable_evalsensorUsage}
Usage with a specific sensor network design:
\begin{unknownListing}
   evalsensor [options...] <sensor-file> <impact-file1> [<impact-file2>...]
\end{unknownListing}
Usage without a sensor network design:
\begin{unknownListing}
   evalsensor [options...] none <impact-file1> [<impact-file2>...]
If none, is specified, then evalsensor will evaluate impacts without any sensors.
\end{unknownListing}

\subsection{Options}\label{evalsensorExecutable_evalsensorOptions}
%\lstinputlisting{examples/simple/command7.txt}
\begin{unknownListing}
     --all-locs-feasible
     A boolean flag to indicate that all locations are treated as feasible.

     --costs=<filename>
     The name of a file that contains the cost information for each node in the network.
	 For more details about the cost file, see File Formats Section `\ref{formats_costFile}`.

     --debug
     A boolean flag to add output information about each incident.

     --format=<type>
     The type of output that the evaluation will generate:
		cout - 	Generates output that is easily read. (default)
		xls - 	Generates output that is easily imported into a MS Excel spreadsheet.
		xml - 	Generates an XML-formatted output to communicate
				with the TEVA-SPOT GUI. (not currently supported)

     --gamma=<num>
     The fraction of the tail distribution used to compute the VaR and TCE
	 performance measures. (default is 0.05)

	 -h, --help
	 A boolean flag to display usage information.

	 --incident-weights=<filename>
	 The name of a file that contains the weights of the different contamination incidents.
	 For more details about the weights file, see File Formats Section `\ref{formats_weightFile}`.

	 --nodemap=<filename>
	 The name of a file that contains the node map information for translating sensor placement
	 indices to EPANET node IDs. For more details about the nodemap file, see File Formats
	 Section `\ref{formats_nodeFile}`.

	 -r, --responseTime=<num>
	 The number of minutes that are needed to respond to the detection of
	 contamination. As the response time increases, the impact increases
	 because the contaminant affects the network for a greater length of
	 time.

	 --sc-probabilities=<filename>
	 The name of a file that contains the probability of detection for each sensor category.
	 For more details about the imperfect sensor class file, see File Formats Section
	 `\ref{formats_sensorClass}`.

	 --scs=<filename>
	 The name of a file that contains the sensor category information for each possible
	 sensor location in the network. For more details about the imperfect junction class file,
	 see File Formats Section `\ref{formats_junctionClass}`.

	 --version
	 A boolean flag to display version information.

	 Note: Options like reponseTime can be specified with the syntax
	 --responseTime 10.0 or --responseTime=10.0.
\end{unknownListing}

\subsection{Arguments}\label{evalsensorExecutable_evalsensorArguments}
\begin{unknownListing}
     <sensor-file>
     A sensor placement file that contains one or more sensor network designs
	 that will be evaluated. If none, is specified, then evalsensor will evaluate
	 impacts without any sensors.

     <impact-file>
     A impact file that contains the impact data concerning the simulated contamination
	 incidents. If one or more impact files are specified, then evaluations are
	 performed for each impact separately.
\end{unknownListing}

%\subsection{Description}\label{evalsensorExecutable_evalsensorDescription}
%The \code{evalsensor} executable takes sensor placements in a Sensor Placement File
%\ref{formats_sensorPlacementFile} and evaluates them using data from an Impact File
%\ref{formats_impactFile} (or a list of impact files). This executable measures the
%performance of each sensor placement with respect to the set of possible
%contamination locations.
%
%See Section \ref{solvers_solvers6} for further description of this command.

max_stars_repo_name: USEPA/Water-Security-Toolkit

max_issues_repo_name: USEPA/Water-Security-Toolkit

max_forks_repo_name: USEPA/Water-Security-Toolkit


text:
\documentclass{tufte-handout}

\usepackage[utf8]{inputenc}

\usepackage{graphicx} % for handling images

\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{microtype}

\usepackage{pgfplots} % layout and margin handling
\pgfplotsset{width=9cm,compat=1.13}

\usepackage{booktabs}
\usepackage{tcolorbox}

\title{Applied Algorithms\newline Optional Assignment \#1}
% \author{Hugo de Brito\newline hubr@itu.dk}

\begin{document}
\thispagestyle{empty}

\maketitle

\includegraphics[width=\textwidth]{logo_en.png}

\vspace{5mm}\noindent %10mm vertical space

\begin{table}[!h]
\centering
\begin{tabular}{cc}
\multicolumn{2}{c}{Authors}                                   \\ \hline
\multicolumn{1}{c|}{\textbf{Hugo Brito}} & \textbf{René Haas} \\
\multicolumn{1}{c|}{\href{mailto:hubr@itu.dk}{hubr@itu.dk}}         & \href{mailto:renha@itu.dk}{renha@itu.dk}       \\ \hline
\end{tabular}
\end{table}

\vspace{5mm} %10mm vertical space

\section{Implement Naive, Recursive, and Strassen's Algorithm, and compare them.}

\noindent Implement the the recursive algorithm and Strassen (for example, in the same JupterLab project), and compare the results in a plot! Submit the code, your plot, and add a few (informal) sentences on your interpretation of the plots.

\section{Files}
This reports the work developed around the implementation of different algorithms for solving square matrix multiplication. The files can be found in the {\tt src} folder and they comprise of:
\begin{itemize}
    \item A Square Matrix Generator -- {\tt squareMatrixGenerator.java}
    \item The Naive Algorithm implementation -- {\tt NaiveMatrixMultiplication.java}
    \item The Recursive Algorithm implementation -- {\tt recursiveMatrixMultiplication.java}
    \item The Strassen's Algorithm implementation -- {\tt strassensMatrixMultiplication.java}
    \item A Java class created for the purpose of reporting the running times -- {\tt expMatrixMultiplication.java}
    \item A {\tt Makefile} instance created for the purpose of running the whole experiment at once
\end{itemize}

\section{Tests}
All the matrix multiplication algorithms pass all tests on Code Judge. Also, to avoid dead code and ensure correctness in the multiplication, we have implemented a method in the {\tt expMatrixMultiplication}, {\tt Arrays.deepEquals} which compares each of the values contained in each cell of the matrices and returns a {\tt boolean} value that informs of the validity of that specific calculation. Every result obtained either via the recursive or the Strassen's algorithms was compared to the one obtained via naive multiplication and returned {\tt true}, which also proves the hypothesis of all algorithms calculating correctly.\\

\section{Experiments}
\begin{tcolorbox}
\begin{itemize}
\item {\bf Question:} Is the running time of the Strassen's algorithm for Matrix Multiplication smaller than the naive and/or the recursive algorithms?
\item {\bf Performance indicators:} Running times
\item {\bf Factors:}
\begin{itemize}
  \item Input type: Matrices $A$ and $B$ of size $n$, containing pseudo-random integers ranging from $a$ to $b$
  \item Pseudo-random seed $= 42$
  \item $n = \left\{2,4,8,16,32,64,128,256,512,1024,2048,4096,8192\right\}$
  \item $[a,b] = [-100, 100]$
\end{itemize}
% \item {\bf Levels:}
\item {\bf Trials: } $10$ repetitions per $n$
% \item {\bf Design Points:}Full factorial
\item {\bf Outputs:} Running times of each of the solving algorithms
\end{itemize}
\end{tcolorbox}

% \bigskip
\noindent
We have ran the described experiment and obtained the running times. These were outputted to a file -- {\tt res01.csv} -- that can be found in the {\tt out} folder. These were plotted and we obtained the following:

\begin{figure}[h!tb]
\centering
%[width=\linewidth]
  \includegraphics[scale=0.67]{out/matrixMultiplication/matrixmult.png}
  \caption{$log_2$ $log_2$ plot of the average running times (nanoseconds) vs. matrix size of the $3$ algorithms}
  \label{fig:Plot}
\end{figure}

\section{Conclusion}
Unfortunately, we could not find any significant difference in the running times between all the $3$ algorithms. We were expecting the running time of the Strassen's algorithm to be slightly better than the naive and the recursive one. Perhaps with bigger matrices the difference would be noticeable, but for now we have no way of being sure.

\end{document}

max_stars_repo_name: hugo-brito/Applied-Algorithms-CodeJudge

max_issues_repo_name: hugo-brito/Applied-Algorithms-CodeJudge

max_forks_repo_name: hugo-brito/Applied-Algorithms-CodeJudge


text:
%-----------------------------------------------------------------------
\chapter{Conclusion}
\label{chap:conclusion}
%-----------------------------------------------------------------------

% Summary of contents
One-step methods including Euler's explicit method, Euler's implicit method, the trapezium rule method and the four-stage Runge-Kutta method were implemented in the software. Other than one-step methods, a predictor-corrector method and two adaptive methods were implemented. The example notebooks provided in Appendix~\ref{chap:link} show that the numerical methods converge for the test problem Eqs.~\eqref{eqn:example_model}-\eqref{eqn:example-end}. Moreover, the orders of accuracy of the one-step methods computed from the test problem Eqs.~\eqref{eqn:example_model}-\eqref{eqn:example-end} are in line with their respective theoretical order of accuracy. While there are no orders of accuracy for the adaptive methods, the accuracy of the method increases with the decrease in tolerance values. These also show that the implemented methods are convergent.

A robust software of ODE solvers is constructed, which includes documentation, version control and testing. The details of the package are documented and available at one of the links in Appendix~\ref{chap:link}. The version control tracks all changes made to the code. The unit testing of the software achieved 100\% code coverage. It tests the initialisation of problem and functionality of methods. These features will allow easier re-use and maintenance of the code, and provide confidence in the correctness of the code.

The software is applied to Fitzhugh-Nagumo model, a model of excitable system. Solutions from various numerical methods exhibit the fast-slow phase and the excitability property of the model. A convergence analysis shows that the numerical solutions are convergent. The adaptive method adapts the mesh points according to the changes in the variable. Moreover, the smaller the tolerance value, the higher the accuracy for adaptive methods.

% Lesson learnt
From this course, I learned about the numerical methods of solving ODEs, especially the theory behind the methods and their orders of accuracy. It provides a basis to choose appropriate methods while solving ODE systems. This knowledge will also give me insight when problems arise in numerical solutions of ODE system. Moreover, while implementing the numerical methods, I realised the difference and difficulty in actual implementation, such as usage of fixed point iteration in solving implicit methods and computation of truncation error. Additionally, the reading on Fitzhugh-Nagumo model helps me in the background knowledge of my D.Phil.~project. I understood the features and properties of Fitzhugh-Nagumo model and excitable systems in general. Finally, having experience in creating a software is really helpful in practicing the software engineering techniques for my D.Phil.~project.

max_stars_repo_name: FarmHJ/numerical-solver

max_issues_repo_name: FarmHJ/numerical-solver

max_forks_repo_name: FarmHJ/numerical-solver


text:
\documentclass[a4paper,11pt]{article}
\usepackage{enumitem}
\usepackage{paralist}
\begin{document}
\title{Support Vector Machines}
\author{Krishna}
\date{July 28, 2020}
\maketitle

\section{Introduction}
Support Vector Machines or SVM are the classifiers.
They use Kernels and Decision boundaries to classify data.

\textbf{Steps of implementation}

\begin{compactenum}
\item\textit{Optimization Objective}
\begin{inparaenum}

    \item{Comparision with Logistic Regression}

    \item{SVM Hypothesis}

\end{inparaenum}

\item\textit{Large Margin Classifier}

\item \textit{Decision Boundaries}
\item \textit{Kernel}
\end{compactenum}

\end{document}

max_stars_repo_name: krishnakesari/Math-representation-of-ML

max_issues_repo_name: krishnakesari/Math-representation-of-ML

max_forks_repo_name: krishnakesari/Math-representation-of-ML


text:
\documentclass[12pt]{article}

\usepackage{timeline}

\begin{document}
\thispagestyle{plain}

\section*{Example of opacity}

I added a 6th argument to timebar to select which step to apply to show years.
I added an optionnal argument for opacity of labels.
It could be nice to centralise this argument as a single value, but don't know where to put it.

\begin{timeline}
 \timebar[2]{|}{0}{2000}{2013}{1}{}

  \entry{2002}{entry}{no opacity}
  \entryshift{2003}{entryshift}{no opacity}{4mm}
  \flipentry{2004}{flipentry}{no opacity}
  \flipentryshift{2005}{flipentryshift}{no opacity}{4mm}

  \entry[0.5]{2008}{entry}{opacity}
  \entryshift[0.5]{2009}{entryshift}{opacity}{4mm}
  \flipentry[0.5]{2010}{flipentry}{opacity}
  \flipentryshift[0.5]{2011}{flipentryshift}{opacity}{4mm}
\end{timeline}

A project I would love to do is also understand how to had a caption !

\newpage

\end{document}

max_stars_repo_name: gowachin/timeline

max_issues_repo_name: gowachin/timeline

max_forks_repo_name: gowachin/timeline


text:
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[onecolumn,10pt]{article}
\usepackage{verbatim,graphicx,hyperref,algorithmic}
\usepackage{amsmath,bm,xcolor}
\usepackage{fontspec,xltxtra,xunicode,unicode-math,hyperref}
\usepackage{unicode-math}
\setmonofont{Menlo}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Palatino}

\newcommand{\com}[1]{{\noindent \color{red}  #1}}
\newcommand{\resp}[1]{{\noindent \color{blue}  #1}}

\title{Clawtalk: a CCG specifier and programming languages maybe for science and stuff implemented in Rust}
\author{Colin LaMont, Aaron Fienberg}

\begin{document}
\maketitle

\section{Introduction: goals for new language}
Before we start, we need some idea of what niche this language will fill.
First and foremost, the language will be a way to learn and have fun whilst studying concepts in linguistics and computer science in a friendship-driven environment.
We have probably learned most of what's cool there is to know about physics, and the rest is hard boring details, dark matter, and maia, the fundamental illusory nature of reality.
But languages and programming languages in particular, are fascinating and thinking about them uses an almost entirely different part of the brain.
So we know why we want to build a programming language.

But why THIS programming language? Here's some brainstorming, and these problems may be entirely the result of the languages I have used (Mathematica, Julia, R, and Matlab.)

\subsection{Memory management and ownership}
The languages I have used before have not done this correctly, but it seems like Rust has done this correctly. We build our system on top of Rust hopefully we should be get this really excellent system for free. We get traits and strict typing and careful, clear distinction between references and values. Just need to learn exactly what Rust is!

\subsection{Safe and fast parameter passing for simulations}
A lot of time I am running simulations with a shit ton of parameters.
The only way I know how to deal with that is by making a really huge struct of all the parameters and passing it through one nested function to the next.
Otherwise the compiler doesn't know if these semi-global parameters change.
It seems like there's no fundamental reason why this should be so difficult, and for me it is a non-trivial time-sink for scientific computing.

My first thought is that we could mix lexical scoping (as the default in functional definitions) with dynamic references, automatically inherited from the enclosing scope. Like say \texttt{mean} is a parameter. Then you could just look for that symbol in the dynamic scope. In Julia this might look like

\begin{verbatim}
function sample(n)
	randn(n) +. &mean::Float
end
\end{verbatim}
reducing to a function with signature \texttt{sample(n, \&mean::Float)}, that automatically get {\em called} with the local manifestation of mean. Just having lexical or dynamic scoping is not enough, we need to be able to mix them.  Seems trivial but doing so in thread-safe way is non trivial.

\subsection{Cool fluid indexing}
I still think indexing could be done better than anyone has done, including \href{https://openreview.net/pdf?id=rJxd7vsWPS}{DEX}, an interesting weird language. I think the closest anyone has gotten is \href{https://en.wikipedia.org/wiki/SequenceL}{SequenceL}, a dead commercial project. It should be possible to mimic mathematical notation almost exactly. Like this should be macro-less, base implementation code.
\begin{verbatim}
a[i k] = sum[j] b[i j] * c[j k]
\end{verbatim}
There's obviously problems settling this space: what if "i" has a constant bound to it? Maybe we default to the symbolic "i" and require interpolation otherwise like
\begin{verbatim}
 i = 3
a[$i k] = sum[j] b[$i j] * c[j k]
> a[3 k] = sum[j] b[3 j] * c[j k]
\end{verbatim}

\subsection{Typed CCG}
The real goal is much more ambitious I want to buld a tool for designing a new language for every kind of problem we might face. Our language would consist of simply a way of specifying a lexicon for a \href{https://en.wikipedia.org/wiki/Combinatory_categorial_grammar}{CCG}, and a parser which reduces ccg sentences into rust code.

CCG's are amazing to me because they seem like a way to encode syntax trees which carry semantic meaning, but without parentheses or block demarcators of any kind like \texttt{ \{ \}}.
Parentheses can unambiguously define a syntax tree with S-expressions, hence the LISP's.
But there are at least two downsides: adding functions means toggling between two sides of an expression in a way that I find annoying (especially being emacs/vim-impaired), and matching parentheses is not natural for humans, and takes a parsing error or two to get it right.  Difficult to read, although the Lisp hackers are practiced.

There have been \href{https://en.wikipedia.org/wiki/Concatenative_programming_language}{concatenative} stack-based languages that do away with parentheses but they are even more difficult to read than parenthetical languages because human language does not work on a strict stack based system.
Spoken language conveys meaning without parentheses and without stacks.

One way language does this is by using functions that have either left or right application directions, and search for categories that match the required valency of the sentence. In languages with inflected cases, you have endings that tell you what the functional role of each word in the sentence is. This combination of directed function application and type declaration / matching is most closely captured mathematically by typed CCG.

CCG's are a description of this combinatorial power of spoken language.  They have the right amount of flexibility to model real languages, without covering every possible weird case of dutch grammar. In a CCG programming language you would define words as a function with a particular valency. Here is zeroth-draft attempt at what syntax would look like

\begin{verbatim}
def the :NounPhrase / a:Noun  # Definition of the word "the"
  known_from_context(a)  # replaces the symbol a with a value from a local context

def a :NounPhrase / a:Noun  # Definition of the word "a"
  instance_of(a)  # instantiates an element of noun class

def bites   a:NounPhrase \  :Sentence  / b:NounPhrase
  first_biting_second(a, b)

def man :Noun
  human_thingy_prefering_male_pronouns

def dog :Noun
  dog_thingy

headline = The man bites a dog
>> first_biting_second(known_from_context(
	human_thingy_prefering_male_pronouns), instance_of(dog_thingy)
	):Sentence
\end{verbatim}

Of course we would use it to do things like defining an associative algebra

\begin{verbatim}
def @  b:tensor \ c:tensor / a:tensor
	 c[i k] = sum[j] b[i... j] * c[j k...]
\end{verbatim}

Once we have some machinery in place it becomes fairly straightforward to write things like
\begin{verbatim}
a = table 10^5 neutrino_events
	with energy = 10 μev
\end{verbatim}
Questions of syntax becomes just what the base lexicon consists of.

I've already broken my promise, it's clear we can't get by on CCG's alone, we have to define procedures which explain what each piece of code does and that means the body of these objects consists of straight rust code \texttt{ \{ \}} blocks and lambda/parentheses.  But at the scalar procedure level, all programming languages are pretty much the same. We just want to enhance the experience of combining scalar procedures in a highly flexible way.

\section{Big picture}
I saw a cool talk where a guy was implementing molecular design on Common Lisp (by compiling to LLVM), and he mentioned how molecules are like these s-expressions and molecular evolution could be elegantly expressed as lisp macros.

In my view, one of the next big revolution will be {\em semantically} parsing genetic code: what does \texttt{CAGCCTTAGA} {\em mean} in a given genetic context? By analogy with the Lisp chemist, a language where the fundamental unit is a lexicon and the compiler is directly evaluating parse trees might have an advantage in this  over a system where a language model has to be specified from scratch. (It might not.).

I also think assembling data pipelines and structures fit for parallelization is also going to be more fun in this hypothetical language (It might be a nightmare).  If we loose faith in this big picture there is always goal 0: to have fun.

\section{Milestones}
What are the goals to know if we are making progress
\begin{enumerate}
\item Come up with a better name. Clawtalk is 5/10 max.
\item Identify and understand a polynomial time normal-form parsing algorithm for typed CCG's in the literature.
\item Explain how this algorithm works in this documentation.
\item Figure out what a good set of practical goals would be to understand how to implement a parser.
\item Identify a system for identifying and resolving syntactical ambiguity
\item Identify a type system for resolving lexical ambiguity
\end{enumerate}

\end{document}

max_stars_repo_name: chelate/clawtalk

max_issues_repo_name: chelate/clawtalk

max_forks_repo_name: chelate/clawtalk


text:
\documentclass[APA,LATO1COL]{WileyNJD-v2}

\articletype{Article Type}%

\received{26 April 2016}
\revised{6 June 2016}
\accepted{6 June 2016}

\raggedbottom

\begin{document}

\title{This is the sample article title\protect\thanks{This is an example for title footnote.}}

\author[1]{Author One*}

\author[2,3]{Author Two}

\author[3]{Author Three}

\authormark{AUTHOR ONE \textsc{et al}}

\address[1]{\orgdiv{Org Division}, \orgname{Org Name}, \orgaddress{\state{State name}, \country{Country name}}}

\address[2]{\orgdiv{Org Division}, \orgname{Org Name}, \orgaddress{\state{State name}, \country{Country name}}}

\address[3]{\orgdiv{Org Division}, \orgname{Org Name}, \orgaddress{\state{State name}, \country{Country name}}}

\corres{*Corresponding author name, This is sample corresponding address. \email{authorone@gmail.com}}

\presentaddress{This is sample for present address text this is sample for present address text}

\abstract[Summary]{}

\keywords{Cloud native, cloud computing, distributed computing}

\jnlcitation{\cname{%
\author{Williams K.},
\author{B. Hoskins},
\author{R. Lee},
\author{G. Masato}, and
\author{T. Woollings}} (\cyear{2016}),
\ctitle{A regime analysis of Atlantic winter jet variability applied to evaluate HadGEM3-GC2}, \cjournal{Q.J.R. Meteorol. Soc.}, \cvol{2017;00:1--6}.}

\maketitle

\footnotetext{\textbf{Abbreviations:} ANA, anti-nuclear antibodies; APC, antigen-presenting cells; IRF, interferon regulatory factor}

\section{Introduction}\label{sec1}

The rest of the paper is organized as follows.

\section{State of the Art}\label{sec2}

Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at, tincidunt tristique, libero. Vivamus viverra
fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper elit. Proin fermentum massa ac
quam. Sed diam turpis, molestie vitae, placerat a, molestie nec, leo~\cite{Rothermel1998} Maecenas lacinia. Nam ipsum ligula, eleifend
at, accumsan nec, suscipit a, ipsum. Morbi blandit ligula feugiat magna. Nunc eleifend consequat lorem. Sed lacinia
nulla vitae enim. Pellentesque tincidunt purus vel magna. Integer non enim. Praesent euismod nunc eu purus. Donec
bibendum quam in tellus. Nullam cursus pulvinar lectus. Donec et mi. Nam vulputate metus eu enim. Vestibulum
pellentesque felis eu massa.
Example for bibliography citations cite~\citep{Elbaum2002}, cites~\cite{Allen2011,Yoo2007}

\begin{figure}[t]
\centerline{\includegraphics[width=342pt,height=9pc,draft]{empty}}
\caption{This is the sample figure caption.\label{fig1}}
\end{figure}

\section{The proposed metaheuristic infrastructure.} \label{infrastructure}

\subsection{Multi-populations using an asynchronous, message-driven system}

\subsection{Methauristics as statess functions}

\subsection{Migration as a reactive system}

\subsection{Multi-experiment setup}

\subsection{Logging}

\subsection{Tools for analisys}

\subsection{Cloud and scaling}

\section{Container-based immplementation}\label{immplementatio}

\subsection{Docker-containers}

\subsection{Docker-compose}

\subsection{Queue, log and configuration}

\subsection{Workers}

\subsection{Controller}

\section{Experimental Setup} \label{setup}
\subsection{Black-Box continuous optimization problems}

\subsection{Hybrid metaheuristics}

\subsubsection{GA metaheuristic}
\subsubsection{PSO metaheuristic}
\subsubsection{GA and PSO metaheuristic}

\subsection{Number of function evaluations}

\subsection{Speedup}
\subsubsection{One to Four workers}

\section{Results} \label{setup}

\begin{center}
\begin{table*}[t]%
\caption{This is sample table caption.\label{tab1}}
\centering
\begin{tabular*}{500pt}{@{\extracolsep\fill}lccD{.}{.}{3}c@{\extracolsep\fill}}
\toprule
&\multicolumn{2}{@{}c@{}}{\textbf{Spanned heading\tnote{1}}} & \multicolumn{2}{@{}c@{}}{\textbf{Spanned heading\tnote{2}}} \\\cmidrule{2-3}\cmidrule{4-5}
\textbf{col1 head} & \textbf{col2 head}  & \textbf{col3 head}  & \multicolumn{1}{@{}l@{}}{\textbf{col4 head}}  & \textbf{col5 head}   \\
\midrule
col1 text & col2 text  & col3 text  & 12.34  & col5 text\tnote{1}   \\
col1 text & col2 text  & col3 text  & 1.62  & col5 text\tnote{2}   \\
col1 text & col2 text  & col3 text  & 51.809  & col5 text   \\
\bottomrule
\end{tabular*}
\begin{tablenotes}%%[341pt]
\item Source: Example for table source text.
\item[1] Example for a first table footnote.
\item[2] Example for a second table footnote.
\end{tablenotes}
\end{table*}
\end{center}

Fusce mauris. Vestibulum luctus nibh at lectus. Sed bibendum, nulla a faucibus semper, leo velit ultricies tellus, ac
venenatis arcu wisi vel nisl. Vestibulum diam. Aliquam pellentesque, augue quis sagittis posuere, turpis lacus congue
quam, in hendrerit risus eros eget felis. Maecenas eget erat in sapien mattis porttitor. Vestibulum porttitor. Nulla
facilisi. Sed a turpis eu lacus commodo facilisis. Morbi fringilla, wisi in dignissim interdum, justo lectus sagittis dui, et
vehicula libero dui cursus dui. Mauris tempor ligula sed lacus. Duis cursus enim ut augue. Cras ac magna. Cras nulla.
Nulla egestas. Curabitur a leo. Quisque egestas wisi eget nunc. Nam feugiat lacus vel est. Curabitur consectetuer.

\begin{algorithm}
\caption{Pseudocode for our algorithm}\label{alg1}
\begin{algorithmic}
  \For each frame
  \For water particles $f_{i}$
  \State compute fluid flow~\cite{Rothermel1997}
  \State compute fluid--solid interaction~\cite{Allen2011}
  \State apply adhesion and surface tension~\cite{Ballen2011}
  \EndFor
   \For solid particles $s_{i}$
   \For neighboring water particles $f_{j}$
   \State compute virtual water film \\(see Section~\ref{sec3})
   \EndFor
   \EndFor
   \For solid particles $s_{i}$
   \For neighboring water particles $f_{j}$
   \State compute growth direction vector \\(see Section~\ref{sec2})
   \EndFor
   \EndFor
   \For solid particles $s_{i}$
   \For neighboring water particles $f_{j}$
   \State compute $F_{\theta}$ (see Section~\ref{sec1})
   \State compute $CE(s_{i},f_{j})$ \\(see Section~\ref{sec3})
   \If $CE(b_{i}, f_{j})$ $>$ glaze threshold
   \State $j$th water particle's phase $\Leftarrow$ ICE
   \EndIf
   \If $CE(c_{i}, f_{j})$ $>$ icicle threshold
   \State $j$th water particle's phase $\Leftarrow$ ICE
   \EndIf
   \EndFor
   \EndFor
  \EndFor
\end{algorithmic}
\end{algorithm}

\begin{equation}\label{eq23}
 \|\tilde{X}(k)\|^2
 =\frac{\left\|\sum\limits_{i=1}^{p}\tilde{Y}_i(k)+\sum\limits_{j=1}^{q}\tilde{Z}_j(k) \right\|^2}{(p+q)^2}
 \leq\frac{\sum\limits_{i=1}^{p}\left\|\tilde{Y}_i(k)\right\|^2+\sum\limits_{j=1}^{q}\left\|\tilde{Z}_j(k)\right\|^2 }{p+q}.
\end{equation}

\section{Conclusions}\label{sec5}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae,
felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec
vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus
sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel
leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur
auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam.
Duis eget orci sit amet orci dignissim rutrum.

Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero,
pretium at, lobortis vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna,
vitae ornare odio metus a mi. Morbi ac orci et nisl hendrerit mollis. Suspendisse ut massa. Cras nec ante. Pellentesque
a nulla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt
urna. Nulla ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris.

%\backmatter

\section*{Acknowledgments}
This is acknowledgment text~\cite{Elbaum2002}. Provide text here. This is acknowledgment text. Provide text here. This is acknowledgment text. Provide text here. This is acknowledgment text. Provide text here. This is acknowledgment text. Provide text here. This is acknowledgment text. Provide text here. This is acknowledgment text. Provide text here. This is acknowledgment text. Provide text here. This is acknowledgment text. Provide text here.

\subsection*{Author contributions}

This is an author contribution text. This is an author contribution text. This is an author contribution text. This is an author contribution text. This is an author contribution text.

\subsection*{Financial disclosure}

None reported.

\subsection*{Conflict of interest}

The authors declare no potential conflict of interests.

\section*{Supporting information}

The following supporting information is available as part of the online article:

\bibliography{concurrent,geneura}%

\section*{Author Biography}

\begin{biography}{\includegraphics[width=60pt,height=70pt,draft]{empty}}{\textbf{Author Name.} This is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text this is sample author biography text.}
\end{biography}

\end{document}