With the following plain TeX:
\hbox to \hsize {
\vbox to 2 true in {
aaa aaaaa aaaaa aaa aaaaa aaaa aaa aaaa aaa. aaa aaaaa aaaaa aaa aaaaa aaaa aaa
aaaa aaa aaa aaaaa aaaaa aaa aaaaa aaaa aaa aaaa aaa. aaa aaaaa aaaaa aaa aaaaa
aaaa aaa aaaa aaa. }
\vbox to 2 true in {
bbb bbbbb bbbbb bbb bbbbb bbbb bbb bbbb bbb. bbb bbbbb bbbbb bbb bbbbb bbbb bbb
bbbb bbb bbb bbbbb bbbbb bbb bbbbb bbbb bbb bbbb bbb. bbb bbbbb bbbbb bbb bbbbb
bbbb bbb bbbb bbb. }
}
the goal is to see two boxes side containing a paragraph or so of text. Except that when TeXed, the first vbox stretches to the full size of \hsize, squeezing the second vbox off the page.
Why doesn't this work as expected? There might be a better way to implement side-by-side paragraphs, but I'm still interested in what's wrong here.
A line of text in a paragraph will always stretch to \hsize (the value of \hsize at the end of that paragraph). Thus, use for example:
\hbox to \hsize {
\vbox to 3 true in {
\hsize=3 true in
\strut aaa aaaaa aaaaa aaa aaaaa aaaa aaa aaaa aaa. aaa aaaaa aaaaa aaa
aaaaa aaaa aaa aaaa aaa aaa aaaaa aaaaa aaa aaaaa aaaa aaa aaaa aaa.
aaa aaaaa aaaaa aaa aaaaa aaaa aaa aaaa aaa.\vfil
}
\hfil
\vbox to 3 true in {
\hsize=3 true in
\strut bbb bbbbb bbbbb bbb bbbbb bbbb bbb bbbb bbb. bbb bbbbb bbbbb bbb
bbbbb bbbb bbb bbbb bbb bbb bbbbb bbbbb bbb bbbbb bbbb bbb bbbb bbb.
bbb bbbbb bbbbb bbb bbbbb bbbb bbb bbbb bbb.\vfil
}
}
Related
I have a Google sheet cell A1 with markdown like this:
Param | Value | Units
--- | --- | ---
**K1** | [PS1\Geral_K1] |ºC
**K2** | [PS1\Geral_K2] |ºC
**K3** | [PS1\Geral_K3] |ºC
All if this is on the same cell, A1.
PS1\Geral_K? is a param to be fetched from another sheet.
So I need to extract the string inside [] and make a vlookup to get the valor for this param.
I already have this code to check I get the result for each group found.
=REGEXREPLACE(A1,"\[([^]]+)\]","$1")
Now I want to use "$1" to vlookup in another table for each of the following
PS1\Geral_K1
PS1\Geral_K2
PS1\Geral_K3
how can I do it ???
This is the result I want to have in B1
Param | Value | Units
--- | --- | ---
**K1** | 100 |ºC
**K2** | 20 |ºC
**K3** | 30 |ºC
paste in D2 and drag down:
=IFERROR(ARRAYFORMULA(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(
QUERY(QUERY({Campos!A:A, Campos!B:B&"♣"&Campos!D:D&"♠"},
"select Col2 where Col1 = '"&A2&"'"), , 999^99),
" ", CHAR(10)), "♣", " "), "♠", " °C")))
I was tinkering with a permutations example from a book. Following code works as intented.
perms([]) -> [[]];
perms(L) -> [[H|T] || H <- L, T <- perms(L--[H])].
And when I substitute the expressions it become this:
[ [1 | perms([2])],
[2 | perms([1])] ]
[ [1 | [[2 | perms([])]]],
[2 | [[1 | perms([])]]] ]
[ [1 | [ [2 | [[]] ] ]],
[2 | [ [1 | [[]] ] ]] ]
And this evaluates correctly to [[1,2], [2,1]].
But when I changed the base case to the empty list from a list contains an empty list:
perms([]) -> [];
It returns an empty list. When I substitute I got this.
[ [1 | [[2 | [] ]]],
[2 | [[1 | [] ]]] ]
I tried both expression with flatten but they yielded same and correct result.
[[1 | lists:flatten([[2 | lists:flatten([[]]) ]])], [2 | lists:flatten([[1 | lists:flatten([[]]) ]])]]
[[1 | lists:flatten([[2 | lists:flatten([]) ]])], [2 | lists:flatten([[1 | lists:flatten([]) ]])]].
So I couldn't figure out the difference between two expressions.
This function implements a recursive algorithm:
What are the permutations of a non-empty list? For each of the elements in the list, take the permutations of the list minus that element and prepend the element to each such permutation.
What are the permutations of an empty list? There is just one: the empty list itself, so we return a list containing one element, namely the empty list: [[]]
By changing the base case to return [] instead of [[]], you're saying:
What are the permutations of an empty list? There are zero permutations.
And then in the recursive case, you get to the step "take the permutations of..." - but there are no permutations, so there is nothing you can prepend elements to.
I'm trying to build a simple grammar for Search Engine query.
I've got this so far -
options {
STATIC=false;
MULTI=true;
VISITOR=true;
}
PARSER_BEGIN(SearchParser)
package com.syncplicity.searchservice.infrastructure.parser;
public class SearchParser {}
PARSER_END(SearchParser)
SKIP :
{
" "
| "\t"
| "\n"
| "\r"
}
<*> TOKEN : {
<#_TERM_CHAR: ~[ " ", "\t", "\n", "\r", "!", "(", ")", "\"", "\\", "/" ] >
| <#_QUOTED_CHAR: ~["\""] >
| <#_WHITESPACE: ( " " | "\t" | "\n" | "\r" | "\u3000") >
}
TOKEN :
{
<AND: "AND">
| <OR: "OR">
| <NOT: ("NOT" | "!")>
| <LBRACKET: "(">
| <RBRACKET: ")">
| <TERM: (<_TERM_CHAR>)+ >
| <QUOTED: "\"" (<_QUOTED_CHAR>)+ "\"">
}
/** Main production. */
ASTQuery query() #Query: {}
{
subQuery()
( <AND> subQuery() #LogicalAnd
| <OR> subQuery() #LogicalOr
| <NOT> subQuery() #LogicalNot
)*
{
return jjtThis;
}
}
void subQuery() #void: {}
{
<LBRACKET> query() <RBRACKET> | term() | quoted()
}
void term() #Term:
{
Token t;
}
{
(
t=<TERM>
)
{
jjtThis.value = t.image;
}
}
void quoted() #Quoted:
{
Token t;
}
{
(
t=<QUOTED>
)
{
jjtThis.value = t.image;
}
}
Looks like it works as I wanted to, e.g it can handle AND, OR, NOT/!, single terms and quoted text.
However I can't force it to handle whitespaces between terms as OR operator. E.g hello world should be treated as hello OR world
I've tried all obvious solutions, like <OR: ("OR" | " ")>, removing " " from SKIP, etc. But it still doesn't work.
Perhaps you don't want whitespace treated as an OR, perhaps you want the OR keyword to be optional. In that case you can use a grammar like this
query --> subquery (<AND> subquery | (<OR>)? subquery | <NOT> subquery)*
However this grammar treat NOT as an infix operator. Also it doesn't reflect precedence. Usually NOT has precedence over AND and AND over OR. Also your main production should look for an EOF. For that you can try
query --> query0 <EOF>
query0 --> query1 ((<OR>)? query1)*
query1 --> query2 (<AND> query2)*
query2 --> <NOT> query2 | subquery
subquery --> <LBRACKET> query0 <RBRACKET> | <TERM> | <QUOTED>
Ok. Suppose you actually do want to require that any missing ORs be replaced by at least one space. Or to put it another way, if there is one or more white spaces where an OR would be permitted, then that white space is considered to be an OR.
As in my other solution, I'll treat NOT as a unary operator and give NOT precedence over AND and AND precedence over either sort of OR.
Change
SKIP : { " " | "\t" | "\n" | "\r" }
to
TOKEN : {<WS : " " | "\t" | "\n" | "\r" > }
Now use a grammar like this
query() --> query0() ows() <EOF>
query0() --> query1()
( LOOKAHEAD( ows() <OR> | ws() (<NOT> | <LBRACKET> | <TERM> | <QUOTED>) )
( ows() (<OR>)?
query1()
)*
query1() --> query2() (LOOKAHEAD(ows() <AND>) ows() <AND> query2())*
query2() --> ows() (<NOT> query2() | subquery())
subquery() --> <LBRACKET> query0() ows() <RBRACKET> | <TERM> | <QUOTED>
ows() --> (<WS>)*
ws() --> (<WS>)+
My website is using Drupal. On first page I have a list of entries and each entry has own URL.
In some cases, I can't understand when, my links looks like:
/node/1%2C157
Instead of:
/node/1157
In my view I found that my content is displayed by this line:
<?php print render($page['content']); ?>
I need to understand where my content is generated and to fix this problem.
Or maybe I can fix this problem from admin panel ?
( I'm using Pathauto and Path modules to rewrite URL's, on other content is working well but in some nodes I have this problem. I tried to regenerate, to remove and generate again but for this nodes nothing happened ).
The %2C occurs in the url because of comma.Please see if you are creating any url with comma in it.This is possibly the cause of such url.
Here is the list of url encoded characters.
URL Encoded Characters
backspace %08
tab %09
linefeed %0A
creturn %0D
space %20
! %21
" %22
# %23
$ %24
% %25
& %26
' %27
( %28
) %29
* %2A
+ %2B
, %2C
- %2D
. %2E
/ %2F
0 %30
1 %31
2 %32
3 %33
4 %34
5 %35
6 %36
7 %37
8 %38
9 %39
: %3A
; %3B
< %3C
= %3D
> %3E
? %3F
# %40
A %41
B %42
C %43
D %44
E %45
F %46
G %47
H %48
I %49
J %4A
K %4B
L %4C
M %4D
N %4E
O %4F
P %50
Q %51
R %52
S %53
T %54
U %55
V %56
W %57
X %58
Y %59
Z %5A
[ %5B
\ %5C
] %5D
^ %5E
_ %5F
` %60
a %61
b %62
c %63
d %64
e %65
f %66
g %67
h %68
i %69
j %6A
k %6B
l %6C
m %6D
n %6E
o %6F
p %70
q %71
r %72
s %73
t %74
u %75
v %76
w %77
x %78
y %79
z %7A
{ %7B
| %7C
} %7D
~ %7E
¢ %A2
£ %A3
¥ %A5
| %A6
§ %A7
« %AB
¬ %AC
¯ %AD
º %B0
± %B1
ª %B2
, %B4
µ %B5
» %BB
¼ %BC
½ %BD
¿ %BF
À %C0
Á %C1
 %C2
à %C3
Ä %C4
Å %C5
Æ %C6
Ç %C7
È %C8
É %C9
Ê %CA
Ë %CB
Ì %CC
Í %CD
Î %CE
Ï %CF
Ð %D0
Ñ %D1
Ò %D2
Ó %D3
Ô %D4
Õ %D5
Ö %D6
Ø %D8
Ù %D9
Ú %DA
Û %DB
Ü %DC
Ý %DD
Þ %DE
ß %DF
à %E0
á %E1
â %E2
ã %E3
ä %E4
å %E5
æ %E6
ç %E7
è %E8
é %E9
ê %EA
ë %EB
ì %EC
í %ED
î %EE
ï %EF
ð %F0
ñ %F1
ò %F2
ó %F3
ô %F4
õ %F5
ö %F6
÷ %F7
ø %F8
ù %F9
ú %FA
û %FB
ü %FC
ý %FD
þ %FE
ÿ %FF
I have a exercise model which has two attributes: title and points. The goal is getting a list of exercises until to reach an amount of points fixed previously. For example:
TABLE: exercises
title | points
==============
aaaaa | 3
bbbbb | 5
ccccc | 10
ddddd | 10
eeeee | 5
fffff | 3
#points <= 14
RESULT
aaaaa | 3
bbbbb | 5
eeeee | 5
or
aaaaa | 3
ccccc | 10
or
ccccc | 10
fffff | 3
... etc ...
Somthing like:
select_values("SELECT * FROM exercises WHERE SUM(points) < 14)
The following SQL should work in MySQL.
SET #psum := 0;
SELECT t1.* FROM (
SELECT m.*,
(#psum := #psum + m.points) AS cumulative_points
FROM (SELECT title, points from Exercises r ORDER BY RAND()) m
) t1
WHERE t1.cumulative_points <= 14;
However the ActiveRecord query would look a bit messy. E.g. something like:
random_exercises = Exercise.transaction do
Exercise.connection.execute("SET #psum = 0;")
# this is returned, because it's the last line in the block
Exercise.find_by_sql(%Q|
SELECT t1.* FROM (
SELECT m.*,
(#psum := #psum + m.points) AS cumulative_points
FROM (SELECT title, points from exercises r ORDER BY RAND()) m
) t1
WHERE t1.cumulative_points <= 14
|)
end
I think you need something like this:
Exercise.where(...).group(...).having('SUM(points) < ?', predefined_value)
Or, in your case, simply:
Exercise.having('SUM(points) < ?', predefined_value)