Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Range-extraction/SNOBOL4/range-extraction.sno
Normal file
22
Task/Range-extraction/SNOBOL4/range-extraction.sno
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
* # Absolute value
|
||||
define('abs(n)') :(abs_end)
|
||||
abs abs = ~(abs = lt(n,0) -n) n :(return)
|
||||
abs_end
|
||||
|
||||
define('rangext(str)d1,d2') :(rangext_end)
|
||||
rangext num = ('+' | '-' | '') span('0123456789')
|
||||
rxt1 str ',' span(' ') = ' ' :s(rxt1)
|
||||
rxt2 str num . d1 ' ' num . d2 =
|
||||
+ d1 ('~,' ? *eq(abs(d2 - d1),1) '~' | ',') d2 :s(rxt2)
|
||||
rxt3 str ('~' | '-') num '~' = '-' :s(rxt3)
|
||||
rxt4 str '~' = ',' :s(rxt4)
|
||||
rangext = str :(return)
|
||||
rangext_end
|
||||
|
||||
* # Test and display
|
||||
test = '0, 1, 2, 4, 6, 7, 8, 11, 12, 14, '
|
||||
+ '15, 16, 17, 18, 19, 20, 21, 22, 23, 24, '
|
||||
+ '25, 27, 28, 29, 30, 31, 32, 33, 35, 36, '
|
||||
+ '37, 38, 39'
|
||||
output = rangext(test)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue