Click here to Skip to main content
16,019,263 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Wordle 1,183 - 3 4 me Pin
pkfox13-Sep-24 20:39
professionalpkfox13-Sep-24 20:39 
GeneralWordle 1,183 - 3/6 Pin
ChandraRam13-Sep-24 22:46
ChandraRam13-Sep-24 22:46 
GeneralRe: Wordle 1,183 Pin
Cp-Coder14-Sep-24 0:57
Cp-Coder14-Sep-24 0:57 
GeneralRe: Wordle 1,183 Pin
PJ Arends14-Sep-24 5:22
professionalPJ Arends14-Sep-24 5:22 
GeneralRe: Wordle 1,183 (4/6) Pin
Jeremy Falcon14-Sep-24 8:25
professionalJeremy Falcon14-Sep-24 8:25 
GeneralRe: Wordle 1,183 Pin
StarNamer@work14-Sep-24 12:12
professionalStarNamer@work14-Sep-24 12:12 
GeneralRe: Wordle 1,183 Pin
jmaida14-Sep-24 12:17
jmaida14-Sep-24 12:17 
GeneralApproximate state machines?! Pin
honey the codewitch13-Sep-24 17:58
mvahoney the codewitch13-Sep-24 17:58 
So I have this embedded SVG mess I'm working on, and being embedded, compromises are often to be made.

One of them is that I don't validate the SVG beyond what I need to parse it. This reduces flash space requirements, and sometimes memory requirements, and can also reduce power/increase execution speed in the margins, although sometimes with more dramatic effect.

Consider the following values for the transform attribute. There can be multiple in a list separated by spaces:
rotate(-10 50 100)
translate(-36 45.5)
skewX(40)
skewY(10)
scale(1 0.5)
matrix(0 0 1 0 1)


Also the space delimiters above may or may not be commas, just to keep things fun, and some of the arguments presented above are not necessarily required

The above would do six transformations in series, as each transformation is presented along with the others, separated by whitespace, resulting in 5 matrix multiplications.

The issue is parsing it.

I don't want to validate all this, because I don't care. So I do things like this:

C++
switch(**current) {
    case 'X':
        ttype = TRANS_SKEW_X;
        state = -1; // -1 parses until (
        break;
    case 'Y':
        ttype = TRANS_SKEW_Y;
        state = -1; // -1 parses until (
        break;
    case 'k':
    case 'e':
    case 'w':
        ++(*current);
        break;
    default:
        return FMT_ERROR;
}


That's all a single state in a larger state machine (not pictured). I've "compressed" (lossy) the parsing of skewX vs skewY into two states, with the final state being shown.

Normally you need like N+1 states where N is the number of characters in the phrase you are parsing.

Here, it will except sekwX for example, but what are the odds that you DIDN'T mean skewX on top of the odds that it happens in the first place?

It's a compromise. This is a renderer, not a validator.

But it got me thinking about approximated state machines like this, and I'm trying to sort of float some codeish equations in my head for how to represent them algorithmically, and I'm not seeing it.

I've got "concepts of a plan", is all. That won't get me far.

But it's interesting to me, the idea of compressing state machines in order to approximately match text. I can easily see the use in embedded.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

GeneralEngineering Nirvana Pin
BernardIE531713-Sep-24 14:37
BernardIE531713-Sep-24 14:37 
GeneralHave You Ever Eaten a Neighbor's Pet? Pin
Steve Raw13-Sep-24 13:48
professionalSteve Raw13-Sep-24 13:48 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
Dr.Walt Fair, PE13-Sep-24 14:10
professionalDr.Walt Fair, PE13-Sep-24 14:10 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
Steve Raw13-Sep-24 14:22
professionalSteve Raw13-Sep-24 14:22 
GeneralI Am a Monster Pin
Steve Raw13-Sep-24 14:32
professionalSteve Raw13-Sep-24 14:32 
GeneralRe: I Am a Monster Pin
jmaida13-Sep-24 17:06
jmaida13-Sep-24 17:06 
GeneralRe: I Am a Monster Pin
dandy7214-Sep-24 4:15
dandy7214-Sep-24 4:15 
JokeRe: I Am a Monster Pin
Richard Deeming15-Sep-24 21:25
mveRichard Deeming15-Sep-24 21:25 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
jschell17-Sep-24 12:56
jschell17-Sep-24 12:56 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
PIEBALDconsult13-Sep-24 14:43
mvePIEBALDconsult13-Sep-24 14:43 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
charlieg14-Sep-24 1:20
charlieg14-Sep-24 1:20 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
dandy7214-Sep-24 4:25
dandy7214-Sep-24 4:25 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
k505414-Sep-24 5:41
mvek505414-Sep-24 5:41 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
charlieg15-Sep-24 17:56
charlieg15-Sep-24 17:56 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
RossMW14-Sep-24 8:54
professionalRossMW14-Sep-24 8:54 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
charlieg15-Sep-24 17:55
charlieg15-Sep-24 17:55 
GeneralRe: Have You Ever Eaten a Neighbor's Pet? Pin
Ron Anders14-Sep-24 2:41
Ron Anders14-Sep-24 2:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.