powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Caché, Ensemble, DeepSee, MiniM, IRIS, GT.M [игнор отключен] [закрыт для гостей] / set $piece()
5 сообщений из 5, страница 1 из 1
set $piece()
    #35161824
Фотография ну я
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Прошу прокомментировать поведение cache в части соответствия стандартам MUMPS

MSM
Код: plaintext
1.
2.
3.
>s str="a,b,c" s $p(str,"", 8 )="d" w str
a,b,cd
>w $zv
MSM for Windows NT, Version  4 . 4 . 1  (RC- 1 )

M3-Lite
Код: plaintext
1.
2.
3.
 3 >s str="a,b,c" s $p(str,"", 8 )="d" w str
a,b,cd
 3 >w $zv
M3-Lite for Windows V2.079e

Cache
Код: plaintext
1.
2.
3.
4.
USER>s str="a,b,c" s $p(str,"", 8 )="d" w str
d
USER>w $zv
Cache for Windows NT (Intel/P4)  5 . 0 . 15  (Build  5802 ) Fri Mar  18   2005   13 : 05 : 32 
EST
...
Рейтинг: 0 / 0
set $piece()
    #35162068
Блок А.Н.
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
я не знаю, какой смысл вкладывается в $p(x,"",y)
есть подозрение, что само выражение не по стандарту, и поэтому СУБД имеет право обработать его по своему усмотрению или вообще выдать ошибку :-)
ИМХО

Более осмысленное выражение
USER>s str="a,b,c" s $p(str,",",8)="d" w str
a,b,c,,,,,d
USER>w $zv
Cache for Windows (Intel) 5.2 (Build 329) Thu Jun 15 2006 16:40:08 EDT

отрабатывается
...
Рейтинг: 0 / 0
set $piece()
    #35163697
Alexey Maslov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Правы MSM и M3-Lite, Cache - нет, согласно
1995 Version of ANSI (Equivalent to Current ISO Version) of StandardFor each setleft that is a setpiece, of the form $Piece(glvn,d,m,n), the value of expr replaces the mth through the nth pieces of the current value of the glvn, where the value of d is the piece delimiter. Note that both m and n are optional. If neither is present, then m = n = 1; if only m is present, then n = m. If glvn has no current value, the empty string is used as its current value. Note that the current value of glvn is obtained just prior to replacing it. That is, the other arguments of setpiece are evaluated in left-to-right order, and the expr to the right of the = is evaluated prior to obtaining the value of glvn.
Let s be the current value of glvn, k be the number of occurrences of d in s, that is, k = max(0,$Length(s,d) - 1), and t be the value of expr. The following cases are defined, using the concatenation operator _ of 7.2.1.1:
m > n or n < 1.
The glvn is not changed and does not change the naked indicator.
n '< m–1 > k.
The value in glvn is replaced by s_F(m–1-k)_t, where F(x) denotes a string of x occurrences of d, when x > 0; otherwise, F(x) = "". In either case, glvn affects the naked indicator.
m–1 '> k < n.
The value in glvn is replaced by $P(s,d,1,m–1)_F(min(m–1,1))_t.
Otherwise,
The value in glvn is replaced by $P(s,d,1,m–1)_F(min(m–1,1))_t_d_$P(s,d,n+1,k+1). Цитирую по The Annotated MUMPS Standards. Ed de Moel.
...
Рейтинг: 0 / 0
set $piece()
    #35164054
Фотография ну я
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
С другой стороны,

Код: plaintext
$l(s,"") =  0  и $p(s,"",n,m) = ""

для любых str, n и m

И наверно вопрос сводится к тому сколько number of occurrences of "" in s. Или сколько в строке пустых подстрок.
...
Рейтинг: 0 / 0
set $piece()
    #35166976
Alexey Maslov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Number of occurrences, по определению: Стандарт... k be the number of occurrences of d in s, that is, k = max(0,$Length(s,d) - 1)$Length(s,"") = 0 => k = max(0, -1) => k = 0. При m>1 имеем m-1 > k, т.е. попадаем в условия варианта: Стандартn '< m–1 > k.
The value in glvn is replaced by s_F(m–1-k)_t, where F(x) denotes a string of x occurrences of d, when x > 0; otherwise, F(x) = "".Имеем F(m-1-k)="", поэтому результат равен s_t.
...
Рейтинг: 0 / 0
5 сообщений из 5, страница 1 из 1
Форумы / Caché, Ensemble, DeepSee, MiniM, IRIS, GT.M [игнор отключен] [закрыт для гостей] / set $piece()
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]