Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

step-version

step-version: func [
    val [tuple!]
    segment [word!] "'major, 'minor, or 'build"
    /local res
][
    switch segment [
        build [res: val + 0.0.1]
        minor [res: val + 0.1.0  res/3: 0]
        major [res: val + 1.0.0  res/2: 0  res/3: 0]
    ]
    either res > val [res] [none]
]

can-step-version?: func [
    val [tuple!]
    segment [word!] "'major, 'minor, or 'build"
][
    either step-version val segment [true] [false]
]

; foreach val [
;     0.0.0 0.0.255
;     0.1.0 0.255.0 0.255.255
;     1.0.0 0.255.255
;     254.255.255 255.255.254
;     255.254.255 254.255.255
; ][
;     foreach seg [build minor major] [
;         print [val tab seg tab can-step-version? val seg tab attempt [step-version val seg]]
;     ]
; ]
; print attempt [step-version 254.255.255 'test]
; halt
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS