294:
29:
179:
of integers 1 through 10. The second ".." is the flip-flop operator, otherwise known as the flip floperator. Note that the number 5 is printed even though both "x == 4" and "x== 6" are false. This is because the expression remembers that "x == 4" was true on a previous iteration, and that "x == 6"
188:
The flip-flop operator needs to store its current state. There is no way for the programmer to explicitly define where this state is stored and what its lifetime is. The lifetime makes a difference when the same code is used by several threads, or in recursive functions. These concurrent accesses to
189:
the state of the flip-flop operator can lead to undefined behavior, or at least surprising results, depending on the programming language. For example, in Perl each flip-flop operator has its own state, shared among all the threads, the other programming languages do the same.
153:
A flip-flop with first condition A and second condition B is not equivalent to "if A and not B", as the former has persistent state and is true even if A is no longer true, as long as at some point in the past A was true and B has always been false.
203:
This flip-flop data type would provide a function that queries and updates its state at the same time. This function gets the actual data on which the switching predicates depend and passes that data to the two predicates, if necessary.
133:
is a seldom-used syntactic construct which allows a boolean to flip from false to true when a first condition is met and then back to false when a second condition is met. The syntax is available in the programming languages
335:
93:
46:
65:
192:
To work around this limitation, the flip-flop operator would have to be modeled as an abstract data type, parameterized with:
72:
359:
79:
112:
354:
61:
50:
328:
139:
17:
207:
Due to this inherent complexity, only few programming languages have adopted the flip-flop operator.
321:
86:
309:
39:
157:
A good analogy would be that even though A is not the truth and B is, It still will believe A.
301:
126:
8:
275:
261:
226:
305:
247:
172:
348:
176:
262:"PyCon Australia Lightning talk: Flip Flop Operators (flip floperators)"
28:
293:
199:
a predicate that tells whether to switch the flip-flop off.
135:
196:
a predicate that tells whether to switch the flip-flop on,
147:
143:
165:
The following Ruby code prints the numbers 4 through 6:
168:(1..10).each do |x| puts x if (x == 4 .. x == 6) end
53:. Unsourced material may be challenged and removed.
346:
329:
245:
336:
322:
113:Learn how and when to remove this message
221:
219:
347:
216:
288:
51:adding citations to reliable sources
22:
180:had at that point never been true.
13:
171:The first instance of ".." is the
14:
371:
292:
142:. Similar logic is available in
27:
227:"Perl operators and precedence"
38:needs additional citations for
268:
254:
239:
1:
210:
308:. You can help Knowledge by
248:"Flip Flop Operator in Ruby"
62:"Flip-flop" programming
7:
246:Nithin Bekal (2014-11-21).
183:
10:
376:
360:Computer programming stubs
287:
160:
15:
276:"Range Operator in Perl"
355:Operators (programming)
304:-related article is a
175:, which produces the
302:computer-programming
127:computer programming
47:improve this article
16:For other uses, see
317:
316:
123:
122:
115:
97:
367:
338:
331:
324:
296:
289:
280:
279:
272:
266:
265:
258:
252:
251:
243:
237:
236:
234:
233:
223:
118:
111:
107:
104:
98:
96:
55:
31:
23:
375:
374:
370:
369:
368:
366:
365:
364:
345:
344:
343:
342:
285:
283:
274:
273:
269:
260:
259:
255:
244:
240:
231:
229:
225:
224:
217:
213:
186:
169:
163:
119:
108:
102:
99:
56:
54:
44:
32:
21:
12:
11:
5:
373:
363:
362:
357:
341:
340:
333:
326:
318:
315:
314:
297:
282:
281:
267:
253:
238:
214:
212:
209:
201:
200:
197:
185:
182:
173:range operator
167:
162:
159:
121:
120:
35:
33:
26:
9:
6:
4:
3:
2:
372:
361:
358:
356:
353:
352:
350:
339:
334:
332:
327:
325:
320:
319:
313:
311:
307:
303:
298:
295:
291:
290:
286:
278:. 2020-08-16.
277:
271:
264:. 2018-08-26.
263:
257:
249:
242:
228:
222:
220:
215:
208:
205:
198:
195:
194:
193:
190:
181:
178:
174:
166:
158:
155:
151:
149:
145:
141:
137:
132:
128:
117:
114:
106:
95:
92:
88:
85:
81:
78:
74:
71:
67:
64: –
63:
59:
58:Find sources:
52:
48:
42:
41:
36:This article
34:
30:
25:
24:
19:
310:expanding it
299:
284:
270:
256:
241:
230:. Retrieved
206:
202:
191:
187:
170:
164:
156:
152:
130:
124:
109:
100:
90:
83:
76:
69:
57:
45:Please help
40:verification
37:
177:enumeration
349:Categories
232:2016-10-21
211:References
103:March 2024
73:newspapers
131:flip-flop
18:Flip-flop
184:Pitfalls
161:Example
87:scholar
89:
82:
75:
68:
60:
300:This
94:JSTOR
80:books
306:stub
146:and
140:Ruby
138:and
136:Perl
129:, a
66:news
148:awk
144:sed
125:In
49:by
351::
218:^
150:.
337:e
330:t
323:v
312:.
250:.
235:.
116:)
110:(
105:)
101:(
91:·
84:·
77:·
70:·
43:.
20:.
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.