#JavaScript (ES6) 110 (削除) 116 (削除ここまで)
JavaScript (ES6) 110 (削除) 116 (削除ここまで)
Straightforward:scan string, c is current digit, l is last digit, o is operator.
F=x=>(l='',[for(c of x)10-c?(v=!l||v&&(o<'<'?l!=c:(o[1]&&c==l)||(o<'='?l<c:o<'>'?c==l:l>c)),l=c,o=''):o+=c],v)
Test In Firefox / FireBug console
;['3<=4!=9>3==3','3<=4!=4','5>5','8==8<9>0!=2>=1']
.forEach(s=>console.log(s,F(s)))
3<=4!=9>3==3 true
3<=4!=4 false
5>5 false
8==8<9>0!=2>=1 true
#JavaScript (ES6) 110 (削除) 116 (削除ここまで)
Straightforward:scan string, c is current digit, l is last digit, o is operator.
F=x=>(l='',[for(c of x)10-c?(v=!l||v&&(o<'<'?l!=c:(o[1]&&c==l)||(o<'='?l<c:o<'>'?c==l:l>c)),l=c,o=''):o+=c],v)
Test In Firefox / FireBug console
;['3<=4!=9>3==3','3<=4!=4','5>5','8==8<9>0!=2>=1']
.forEach(s=>console.log(s,F(s)))
3<=4!=9>3==3 true
3<=4!=4 false
5>5 false
8==8<9>0!=2>=1 true
JavaScript (ES6) 110 (削除) 116 (削除ここまで)
Straightforward:scan string, c is current digit, l is last digit, o is operator.
F=x=>(l='',[for(c of x)10-c?(v=!l||v&&(o<'<'?l!=c:(o[1]&&c==l)||(o<'='?l<c:o<'>'?c==l:l>c)),l=c,o=''):o+=c],v)
Test In Firefox / FireBug console
;['3<=4!=9>3==3','3<=4!=4','5>5','8==8<9>0!=2>=1']
.forEach(s=>console.log(s,F(s)))
3<=4!=9>3==3 true
3<=4!=4 false
5>5 false
8==8<9>0!=2>=1 true
#JavaScript (ES6) 116110 (削除) 116 (削除ここまで)
Straightforward:scan string, c is current digit, l is last digit, o is operator.
F=x=>(l='',[for(c of x)10-c?(v=!l||v&&(o<'<'?l!=c:(o[1]&&c==l)||(o<'='?o>'<'?l<=c:l<c:o>'>'?l>=c:o<'>'?l==cc==l:l>c)),l=c,o=''):o+=c],v)
Test In Firefox / FireBug console
;['3<=4!=9>3==3','3<=4!=4','5>5','8==8<9>0!=2>=1']
.forEach(s=>console.log(s,F(s)))
3<=4!=9>3==3 true
3<=4!=4 false
5>5 false
8==8<9>0!=2>=1 true
#JavaScript (ES6) 116
Straightforward:scan string, c is current digit, l is last digit, o is operator.
F=x=>(l='',[for(c of x)10-c?(v=!l||v&&(o<'<'?l!=c:o<'='?o>'<'?l<=c:l<c:o>'>'?l>=c:o<'>'?l==c:l>c),l=c,o=''):o+=c],v)
Test In Firefox / FireBug console
;['3<=4!=9>3==3','3<=4!=4','5>5','8==8<9>0!=2>=1']
.forEach(s=>console.log(s,F(s)))
3<=4!=9>3==3 true
3<=4!=4 false
5>5 false
8==8<9>0!=2>=1 true
#JavaScript (ES6) 110 (削除) 116 (削除ここまで)
Straightforward:scan string, c is current digit, l is last digit, o is operator.
F=x=>(l='',[for(c of x)10-c?(v=!l||v&&(o<'<'?l!=c:(o[1]&&c==l)||(o<'='?l<c:o<'>'?c==l:l>c)),l=c,o=''):o+=c],v)
Test In Firefox / FireBug console
;['3<=4!=9>3==3','3<=4!=4','5>5','8==8<9>0!=2>=1']
.forEach(s=>console.log(s,F(s)))
3<=4!=9>3==3 true
3<=4!=4 false
5>5 false
8==8<9>0!=2>=1 true
#JavaScript (ES6) 116
Straightforward:scan string, c is current digit, l is last digit, o is operator.
F=x=>(l='',[for(c of x)10-c?(v=!l||v&&(o<'<'?l!=c:o<'='?o>'<'?l<=c:l<c:o>'>'?l>=c:o<'>'?l==c:l>c),l=c,o=''):o+=c],v)
Test In Firefox / FireBug console
;['3<=4!=9>3==3','3<=4!=4','5>5','8==8<9>0!=2>=1']
.forEach(s=>console.log(s,F(s)))
3<=4!=9>3==3 true
3<=4!=4 false
5>5 false
8==8<9>0!=2>=1 true