A
A
Alexey Pavlov2018-04-22 18:42:35
css
Alexey Pavlov, 2018-04-22 18:42:35

Why doesn't this "script" on less run?

I have a 10x10 matrix. I want to select a triangle (from squares) on the side in it, occupying almost half of the "matrix" block.
5adcadf9a670e171662540.png
My algorithm is this:

  1. First select all squares with coordinates 2;1, 3;2, 4;3... (internal impurity)
  2. Now the same for squares 3;1, 4;2, 5;3... and so on.

And here is the code that doesn't work. I've heard that the algorithms on less are similar to functional programming, which I'm not good at, so I want to know why this code doesn't compile to css (though no errors occur):
@tens: 2;
@ones: 1;
@reones: 8;
@num: @tens * 10 + @ones;
.mixin2(@tens, @reones) when (@tens =< 9) {
  .mixin(@num) when (@num =< ~"[email protected]{reones}") {
    .square:nth-child(@{num}) {
      animation: none;
      background-color: black;
    }
    .mixin(@num: @num + 1);
  }
  .mixin2(@tens: @tens + 1, @reones: @reones - 1);
}
.mixin2(@tens, @reones);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Pavlov, 2018-04-22
@AlekseyPavlov

Exactly! Exactly! I specified a mixin within a mixin, but forgot to call it!

F
forspamonly2, 2018-04-22
@forspamonly2

.diag(@i: 0) when(@i < 100)
{
  @x: mod(@i, 10);
  @y: floor(@i / 10);
  @squareI: @i + 1;
  .square:nth-child(@{squareI}) when(@x < @y)
  {
    background: black;
  }
  .diag(@i + 1);
}
.diag();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question