Emacs auctex inserts line breaks after inline math in an ugly way - emacs

I got problems with emacs/auctex fill paragraph which insert linebreaks after each $blabla$ block, resulting in a poorly readable code. For exemple, hitting M-q on the following long line:
a $1$ b $2$ c $3$ d $4$ e $5$ f $6$ g $7$ h $8$ i $9$ j $10$ k $11$ l $12$ m $13$ n $14$ o $15$
Gives:
a $1$
b $2$
c $3$
d $4$
e $5$
f $6$ g $7$ h $8$ i $9$ j $10$ k $11$ l $12$ m $13$ n $14$ o $15$
I would like to have something like:
a $1$ b $2$ c $3$ d $4$ e $5$ f $6$ g $7$ h $8$ i $9$ j $10$ k
$11$ l $12$ m $13$ n $14$ o $15
Note: I have the impression that fill-paragraph didn't have this ugly behavior when I didn't use auctex but the built-in latex mode...
Any ideas?
Many thanks!

This can be fixed by changing the AUCTeX user option LaTeX-fill-break-at-separators (see AUCTeX Manual [Filling]).
Hit M-x and type customize-group in the minibuffer, then type LaTeX.
Now you should be able to see the option LaTeX Fill Break At Separators in the newly created buffer. Click on it (expanding it) and uncheck the box next to Closing Inline Math Switches. Don't forget to save.

Related

Writing numbers only each second and third line in Fortran

I am fighting with trying to get numbers 1 and 2 only on each second and third line in the second column.
I have a file tisk2 with
O
H
H
O
H
H
And I need to get to file tisk this:
O
H1
H2
O
H1
H2
I mean I want no number no text after O. I tried to write this code:
program cislo
implicit none
integer :: i, sum, j, k
character :: t*10, m*10
open(10,file="tisk2",status='old')
open(12,file="tisk",status='old')
do k=0,5
read(10,*) m
enddo
do j=1,3
do i = 0,0
t=" "
print*, t
exit
enddo
sum=0
do i=1,2
write(12,fmt='(a2,i2)') m, i
enddo
enddo
end program cislo
I can print only i and I get nothing, second line 1 and third line 2. Then alone print m. But when I want to put both to one file, it skips O and writes to file only H1, H2 and then again. Does anyone has an idea how to get what I need? Thank you for help.

Accessing external (DSPF) fields using arrays in RPGLE free

In the old RPG III and the non-free RPGLE/RPG IV you could "rename" fields you get from either a record of a PF/LF or a record from a DSPF.
This lead to possibilities like grouping several lines of input (additional order text) into a array. So I didn't have to MOVEL or EVAL ottxt1 to the external described field x1txt1, ottxt2 to x1txt2 and so on.
I'd only had to rename the LF record and the DSPF record fields to the array-fields, read the record and shift them from the one array to the other and display my DSPF record
H DECEDIT('0,') DATEDIT(*DMY.) dftactgrp(*no)
Fsls001 cf e workstn
Fordtxtl0 if e k disk
D ot s 20a dim(6)
D x1 s 20a dim(6)
Iordtxtr
I ottxt1 ot(1)
I ottxt2 ot(2)
I ottxt3 ot(3)
I ottxt4 ot(4)
I ottxt5 ot(5)
I ottxt6 ot(6)
Isls00101
I x1txt1 x1(1)
I x1txt2 x1(2)
I x1txt3 x1(3)
I x1txt4 x1(4)
I x1txt5 x1(5)
I x1txt6 x1(6)
C k$or00 klist
C kfld otonbr
C kfld otopos
C eval otonbr = 2
C eval otopos = 2
C k$or00 chain ordtxtr
C if %found(ordtxtl0)
C eval x1 = ot
C endif
C
C exfmt sls00101
C
C move *on *inlr
But is this also possible in *FREE RPGLE? And if so, how?
You can define data structures containing the fields from the files, and overlay them with an array.
Replace your I specs and array definitions with these data structures. You don't have to specify anything besides the field names for the fields from the externally-described file.
dcl-ds otDs;
ottxt1;
ottxt2;
ottxt3;
ottxt4;
ottxt5;
ottxt6;
ot like(ottxt1) dim(6) pos(1);
end-ds;
dcl-ds x1Ds;
x1txt1;
x1txt2;
x1txt3;
x1txt4;
x1txt5;
x1txt6;
x1 like(x1txt1) dim(6) pos(1);
end-ds;

Applying an operation on each element of nested list

I have a complex nested list (depth can be >2 also):
p:((`g;`d1`d2);(`r;enlist `e1);(`r;enlist `p1))
How to add an element to each element of the nested list but retaining the original structure; e.g. adding `h to each element of p to get the following :
((`g`h;(`d1`h;`d2`h));(`r`h;enlist `e1`h);(`r`h;enlist `p1`h))
I tried this but doesn't give what I want :
q)p,\:`h
((`g;`d1`d2;`h);(`r;enlist `e1;`h);(`r;enlist `p1;`h))
q)raze[p],\:`h
(`g`h;`d1`d2`h;`r`h;`e1`h;`r`h;`p1`h)
You can use .z.s to recursively go through the nested list and only append `h to lists of symbols:
q){$[0=type x;.z.s'[x];x,\:`h]}p
g h d1 h d2 h
`r`h ,`e1`h
`r`h ,`p1`h
For this function I have made the assumption that your nested lists will only contain symbols. It checks the type of the list, if it is not a mixed list then it appends `h to each element. If it is a mixed list then it passes each element of that list back into the function separately to check again.
Although not recursive (and so requires some knowledge about the shape of your nested list), a more conventional approach would be
q).[p;2#(::);,';`h]
g h d1 h d2 h
`r`h ,`e1`h
`r`h ,`p1`h
Though Thomas has already answered the question; In case you want to specify any other operation apart from append, you can use the following :
q)f:{`$ "_" sv string x,y}
q){[o;a;e] $[-11<>type e; .z.s [o;a] each e; o[e;a]] }[f;`h] each p
`g_h `d1_h`d2_h
`r_h ,`e1_h
`r_h ,`p1_h
or when f is assigned as append operation
q)f:{x,y}
q){[o;a;e] $[-11<>type e; .z.s [o;a] each e; o[e;a]] }[f;`h] each p
g h d1 h d2 h
`r`h ,`e1`h
`r`h ,`p1`h

Pumping Lemma for anb2n+1

I know how to solve pumping lemma for anbn :n>=0
But I don't understand how can I solve this example : anb2n+1 :n>=0
I tried to solve it but I am not sure that I have solved it correctly or not?Could somebody please help me here?
I can show how did I solve it. But seriously I am not sure is it correct or not. Could you please give me the correct one if I am wrong.
Question : Prove that anb2n+1 :n>=0 is not regular.
Here is my answer.
Assume L is regular. Then pumping lemma must hold. Let m be an integer in Pumping lemma.
Let w=amb2m+1 also in L. and |w|>=m
By Pumping lemma w=xyz where |xy|<=m and |y|>=1
According to pumping lemma wi=xyiz also in L for i=0,1,2,...
Let i=2 then w2=xyyz.
Let y=ak where 1<=k<=m and x=aq where 0<=q< m then z=am-q-kb2m+1
w2=xyyz = aqakakam-q-kb2m+1
= am+kb2m+1
but this is not in L for any value of 1<=k<=m
So we have contradiction with pumping lemma. so, our assumption that L is regular is wrong. So, L can not be regular.
Is this correct???
Thank you.
x=ak
y=aj
z=am-j-kb2m+1
Taking i=m+2 you have:
am+m+1b2m+1 ==> a2m+1b2m+1 that isn't in L.
Pumping Lemma is used to prove that a Language is NOT REGULAR
If A is a Regular Language, then A has a Pumping Length 'P' such
that any string 'S where |S|>=P may be divided into 3 parts S=xyz such
that the following conditions must be true:
(1) xyz & A for every i>0
(2) |y|>0
(3) |xy| <=P
To prove that a language is not Regular using PUMPING LEMMA, follow
the below steps:
(We prove using Contradiction) -> Assume that A is Regular
-> It has to have a Pumping Length (say P)
→ All strings longer than P can be pumped |S|>=P -> Now find a string
'S' in A such that |S|>P
-> Divide S into x y z
-> Show that x y z & A for some i -> Then consider all ways that S can be divided into xyz
-> Show that none of these can satisfy all the 3 pumping conditions at the same time →S cannot be Pumped == CONTRADICTION
To prove this given expression is regular by a example: Assume that
A={a^nb^2n+1|n>=0} is regular Pumping length=p
|S|=3p+1>=p |S|>=p Divide s into x y z Let p=3,and
s=aaabbbbbbb
Case1: The y is in a's part a -> x aa -> y bbbbbbb -> z xy^iz
i=2
xy^2z=>a aaaa bbbbbbb
xy^2z is not belongs to A
Case2: The y is in b's part aaa -->x bb --> y
bbbbb -->z
xy^iz
i=2
xy^2z=> aaa bbbb bbbbb
xy^2z is not belongs to A
Case3: The y is in both a and b parts a-> x
aabb ->y
bbbbb -> z
xy^iz
i=2
xy^2z=> a aabbaabb bbbbb
xy^2z is not belongs to A */ we got contradiction Hence given
expression is not regular
FOR BETTER UNDERSTANDING ABOUT PUMPING LEMMA PLEASE GO THROUGH THE LINK
https://youtu.be/Ty9tpikilAo

Maple: simplifying Im(a+I*b) - why it does not work for me?

So I want to simplify z:=a+I*b; Im(z) where a, b are real variables So I try:
s:= 1+2*I
Im(s) // outputs 2
z:=a+I*b
Im(z) // outputs Im(a+I*b)
So I wonder is it any how possible to simplify Im(z) so to get b as output (here we look at general case meaning z could be any complex expression from real values (like a, b, c etc and complex I))?
You didn't tell Maple that a and b were real, so the simplification doesn't work because it doesn't necessarily hold. One way to get what you want is by using the assume command to let it know:
> s:=1+2*I;
s := 1 + 2 I
> Im(s);
2
> z:=a+I*b;
z := a + b I
> Im(z);
Im(a + b I)
> assume(a,real);
> assume(b,real);
> z;
a~ + b~ I
> Im(z);
b~
The evalc command works by considering unknowns as being real.
z:=a+I*b:
Im(z);
Im(a + I b)
evalc( Im(z) );
b
See its help-page, ?evalc.