How to use for loop in FEEL language in DMN Diagram by Enterprise Architecture - enterprise-architect

FEEL language is not fully supported by Enterprise Architecture. For example, for loop command in this language is not supported by EA.
for i in [1,2,3] return i * i
result:
Running Decision Validations ...
Validating Decision 'Decision' ...
Warning : 'Decision': Context Entry #1 : 'Expression can not be parsed. ' for i in [1, 2 , 3] return i * i''
Decision Results: (0) error(s), (1)warning(s)

Related

R/exams Moodle: Cloze with numeric and a string item

I am trying to use exams package to create my Moodle exams. I want to create a cloze question whit 3 numeric and one string sub-types but I am having problems with the exams2moodle().
Here is a simplification of my code:
```{r data generation, echo = FALSE, results = "hide"}
## DATA GENERATION
options(scipen = 999)
#here in my version, I generated the data and solutions, but I simplified the code for a better understanding
cambio_delta <- 20.1
r2 <- 0.97
y0_1 <- 19.56
sol_str<- "Not possible"
```
Question
========
Here goes the question speech
Answerlist
----------
* Question 1 (this is numeric)
* Question 2 (this is numeric)
* Question 3 (this is numeric)
* Question 4 (this is STRING, the answer suppose to be "Not possible")
Meta-information
================
extype: cloze
exclozetype: num|num|num|string
exsolution: `r 100*r2`|`r cambio_delta`|`r y0_1`|`r sol_str`
extol: 0.05|0.05|0.05
exname: regresion
When I knit this in the Rmarkdown, it works well, but not with exams2moodle():
exams2moodle("regresion.Rmd", n = 8, name = "Exam reg")
I get the warning message:
Error in split.default(solutionlist, gr) :
first argument must be a vector
I will appreciate any suggestion! Thank you!
I put the R/Markdown exercise into a file regresion.Rmd and then ran your code with both exams 2.3-6 (the current CRAN release version at the time of writing) and 2.4-0 (the current R-Forge devel version). Everything worked fine without error and the exercises worked as intended after import into Moodle.
I suggest that you update your version of the exams package and if necessary of R itself. Then you should be fine.

Local variable in map task?

Is there a way to define a local variable in an inline reporter task with map?
This
to go
show map [? * ?] [1 2 3]
end
displays [1 4 9], as expected. What's in the first set of brackets is a "reporter task".
What if I want to use let in the task?
to go
show map [
let sq ? * ?
sq + 1
]
[1 2 3]
end
Error: "Expected a reporter task here, rather than a list or block." The entire first bracketed expression is highlighted as what's producing the syntax error.
Maybe I need to add the task keyword to tell NetLogo that this is a task? The Programming Guide says that "the task primitive is optional" for map but it's worth a try. This works:
to go
show map (task [? * ?]) [1 2 3]
end
but this doesn't:
to go
show map (task [
let sq ? * ?
sq + 1
])
[1 2 3]
end
The second instance of sq is highlighted, with the error message "Expected command." It's odd the error is different this time.
Maybe I need to add report?
to go
show map (task [
let sq ? * ?
report sq + 1
])
[1 2 3]
end
This is syntactically acceptable, but when I run it I get a runtime error: "MAP expected input to be a reporter task but got the command task (command task from: procedure GO) instead."
The only alternative I've found that works is to define a separate reporter:
to go
show map square-plus-one [1 2 3]
end
to-report square-plus-one [n]
let sq n * n
report sq + 1
end
This's easy enough. However, I'm curious whether there's something I'm missing. Is there a way to use local variables in an inline reporter task?
Reporter tasks with complex reporters are not currently possible. See the “Limitations” section in the Programming Guide, under "Tasks":
Reporter tasks can't contain commands, only a single reporter expression.
https://github.com/NetLogo/NetLogo/issues/351 is related — it specifically discusses the problem of needing to refer to a ? variable from an outer scope.

Type conversion in VHDL: real to integer - Is the rounding mode specified?

While debugging the handling of user defined physical types in Vivado (read more), I found a different behavior for type conversions from real to integer.
Here is my example code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.MATH_REAL.all;
entity Top_PhysicalTest_Simple is
port (
Clock : in STD_LOGIC;
Input : in STD_LOGIC;
Output : out STD_LOGIC
);
end;
architecture top of Top_PhysicalTest_Simple is
constant int_1 : INTEGER := natural(0.5);
constant int_2 : INTEGER := integer(-0.5);
-- constant int_2 : INTEGER := natural(-0.5);
begin
assert FALSE report "16 - int_1 (natural(0.5)): " & INTEGER'image(int_1) severity note;
assert FALSE report "17 - int_2 (natural(-0.5)): " & INTEGER'image(int_2) severity note;
Output <= Input when rising_edge(Clock);
end;
The dummy flip flop is used to prevent some tools from complaining about an empty design.
XST 14.7:
Elaborating entity <Top_PhysicalTest_Simple> (architecture <top>) from library <work>.
Note: "16 - int_1 (natural(0.5)): 1"
Note: "17 - int_2 (natural(-0.5)): 0"
XST seems to use the mode round up and it handles the type conversion inclusive range check.
So I must use integer(-0.5) instead of natural(-0.5).
Vivado 2014.4:
[Synth 8-63] RTL assertion: "16 - int_1 (natural(0.5)): 1" ["D:/Temp/PhysicalTest_Vivado2014.4/vhdl/Top_PhysicalTest_Simple.vhdl":80]
[Synth 8-63] RTL assertion: "17 - int_2 (natural(-0.5)): -1" ["D:/Temp/PhysicalTest_Vivado2014.4/vhdl/Top_PhysicalTest_Simple.vhdl":81]
Synth seems to use the mode round to infinity and it handles the type conversion without range check. So maybe natural(..) is just an alias to integer(..).
The commented line: constant int_2 : INTEGER := natural(-0.5); throws no error.
GHDL 0.29:
GHDL 0.29 does no range check in natural(..).
I know it's out dated, but since 0.31 hates me I can't tell if this is already fixed.
GHDL 0.31:
I'll present the results later. GHDL refuses to analyse my code because:
Top_PhysicalTest_Simple.vhdl:29:14: file std_logic_1164.v93 has changed and must be reanalysed
My questions:
Does VHDL define a rounding mode? And if so which one?
How should I handle rounding if no mode is defined?
From IEEE Std 1076-2002 section 7.3.5 "Type conversions"
The conversion of a floating point value to an integer type rounds to
the nearest integer; if the value is halfway between two integers,
rounding may be up or down.
If you want something else, maybe functions in IEEE.MATH_REAL can be of some use (notably CEIL, FLOOR and/or TRUNC).
( posting this as an answer because I can't post a comment inline... )
Here are the results using the prebuilt ghdl-0.31-mcode-win32 :
C:\brian\jobs\ghdl_test\paebbels>md work.ghd
C:\brian\jobs\ghdl_test\paebbels>ghdl -a --workdir=work.ghd Top_PhysicalTest_Simple.vhd
C:\brian\jobs\ghdl_test\paebbels>ghdl -r --workdir=work.ghd Top_PhysicalTest_Simple
Top_PhysicalTest_Simple.vhd:18:3:#0ms:(assertion note): 16 - int_1 (natural(0.5)): 1
Top_PhysicalTest_Simple.vhd:19:3:#0ms:(assertion note): 17 - int_2 (natural(-0.5)): -1
"0.31 is my Windows machine (mcode version)"
"GHDL refuses to analyse my code "
If you're having trouble with libraries on the Windows mcode build of 0.31, try uninstalling any 0.29 or earlier NSIS-installer versions of GHDL on that machine.
Also make sure you ran the through the whole setup process as described in the 0.31 Windows INSTALL, particularly reanalyze_libraries.bat
Here's the version used for the above test:
C:\brian\jobs\ghdl_test\paebbels>ghdl -v
GHDL 0.31 (20140108) [Dunoon edition] + ghdl-0.31-mcode-win32.patch
Compiled with GNAT Version: GPL 2013 (20130314)
mcode code generator
Written by Tristan Gingold.
Copyright (C) 2003 - 2014 Tristan Gingold.
GHDL is free software, covered by the GNU General Public License. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
And the library path info :
C:\brian\jobs\ghdl_test\paebbels>ghdl --dispconfig
command line prefix (--PREFIX): (not set)
environment prefix (GHDL_PREFIX): C:\Ghdl\ghdl-0.31-mcode-win32\lib
default prefix: C:\Ghdl\ghdl-0.31-mcode-win32\lib
actual prefix: C:\Ghdl\ghdl-0.31-mcode-win32\lib
command_name: C:\Ghdl\ghdl-0.31-mcode-win32\bin\ghdl.exe
default library pathes:
C:\Ghdl\ghdl-0.31-mcode-win32\lib\v93\std\
C:\Ghdl\ghdl-0.31-mcode-win32\lib\v93\ieee\

Business Rules Xtext Grammar

At work we use a Business Rules language that was original designed for 'business' people to program but now has fallen on use, the programmers. The IDE/Eclipse plugin isn't what a we would call an 'IDE', but now that a Eclipse plugin has been added in the latest release of the standalone IDE we want to create a Eclipse Editor plugin with syntax coloring, checking etc.
I've been looking at Xtext tutorials but just can't seem to get a grasp on the concept of the grammarlanguage and was hopping if I provided some examples of the Business language someone could provide a grammarexample and some explanation and to what it was doing.
Examples:
varString is a string initially "Dog"; //String - 'a' can be interchanged with 'an'
varInteger is a integer initially 0; //Integer - 'a' can be interchanged with 'an'
varObject is some MyObject initially MyObject.newInstance( "Foo" ); //Object Creation
while ( varInteger < varObject.size() ) do {
varTemp = methodCall( parm1,
parm2,
parm3, );
varTemp1 = methodCallWithCast( parm1,
parm2,
parm3, ) as a MyObject; //'a' can be interchanged with 'an'
}
if ( varObject.size() > 0 ) then {
}
if ( varObject is not null and
varObject.size() < 0 ) then {
}
Note that the styling (spaces after/before the brackets, parameters on seperate lines) I'm hopping to be able to checking as this is the coding standard the we adhear to, and to throw an error if it is not followed
Thanks!
You need to learn about BNF (see http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form) so you can understand how grammar rules are written, and then you need to either find the reference document for your business rules languages, or write your own grammar rules.
With that, you can then consider how XText might be configured to help you.
I suspect that given where you are in your understanding of language processing tools, integrating your business rules language into XText may be more than you are ready to do.

Problem with the deprecation of the postgresql XML2 module 'xml_is_well_formed' function

We need to make extensive use of the 'xml_is_well_formed' function provided by the XML2 module.
Yet the documentation says that the xml2 module will be deprecated since "XML syntax checking and XPath queries"
is covered by the XML-related functionality based on the SQL/XML standard in the core server from PostgreSQL 8.3 onwards.
However, the core function XMLPARSE does not provide equivalent functionality since when it detects an invalid XML document,
it throws an error rather than returning a truth value (which is what we need and currently have with the 'xml_is_well_formed' function).
For example:
select xml_is_well_formed('<br></br2>');
xml_is_well_formed
--------------------
f
(1 row)
select XMLPARSE( DOCUMENT '<br></br2>' );
ERROR: invalid XML document
DETAIL: Entity: line 1: parser error : expected '>'
<br></br2>
^
Entity: line 1: parser error : Extra content at the end of the document
<br></br2>
^
Is there some way to use the new, core XML functionality to simply return a truth value
in the way that we need?.
Thanks,
-- Mike Berrow
After asking about this on the pgsql-hackers e-mail list, I am happy to report that the guys there agreed that it was still needed and they have now moved this function to the core.
See:
http://web.archiveorange.com/archive/v/alpsnGpFlZa76Oz8DjLs
and
http://postgresql.1045698.n5.nabble.com/review-xml-is-well-formed-td2258322.html