m (Sorry)
 
(29 intermediate revisions by 15 users not shown)
Line 1: Line 1:
{{Incorrect Title|() < ()}}
+
{{April Fools}}{{Incorrect Title|() < () (block)}}
{{Block
+
{{block
 
|name = () < ()
 
|name = () < ()
|image = File:()_is_less_than_().png
+
|image = () < ()
 
|category = [[Operators Blocks|Operators]]
 
|category = [[Operators Blocks|Operators]]
 
|type = [[Boolean Block|Boolean]]
 
|type = [[Boolean Block|Boolean]]
|defaults = Blank insert; blank insert
+
|sb = yes
 
}}
 
}}
The '''() < ()''' block is an [[Operators Blocks|Operators block]] and a [[Boolean Block|Boolean block]]. The [[Blocks|block]] checks if the first value is less than the second value {{-}} if it is less, the block returns ''true''; if it is not, it returns ''false''.
+
The '''() < ()''' [[Blocks|block]] is an [[Operators Blocks|Operators block]] and a [[Boolean Block|Boolean block]]. The block reports ''true'' if the first value is less than the second value and ''false'' otherwise.
  
This block works with letters too, not just numbers. In [[Scratch]], letters at the top of the alphabet (ie. a, b, c) are worth less than letters at the end (ie. x, y, z). In [[Scratch 1.3]] and lower, it only accepted numbers.
+
This block can compare both numbers and [[string]]s, which are ordered alphabetically. In [[Scratch 1.3]] and previous versions, it only accepted numbers.
  
==Workaround==
+
==Example Uses==
 +
Some common uses for the () < () block are below:
 +
 
 +
* [[Sorting Values|Sorting]]
 +
* Inserting an item in a sorted [[list]]
 +
 
 +
<scratchblocks>
 +
set [i v] to [1]
 +
repeat until <<(i) > (length of [scores v])> or <(item (i) of [scores v]) < (score)>>
 +
    change [i v] by (1)
 +
end
 +
insert (score) at (i) of [scores v]
 +
</scratchblocks>
 +
 
 +
* Evaluating numbers or letters
 +
 
 +
<scratchblocks>
 +
if <(score) < (5)> then
 +
    say [Poor job.] for (1) secs
 +
    stop [this script v]
 +
end
 +
if <(item (i) of [scores v]) < (10)> then
 +
    say [Well done.] for (1) secs
 +
    stop [this script v]
 +
end
 +
say [Great!] for (1) secs
 +
</scratchblocks>
 +
 
 +
* Comparing different [[variable]]s
 +
 
 +
<scratchblocks>
 +
if <(score 1) < (score 2)> then
 +
    say [Player 2 wins!]
 +
else
 +
    say [Player 1 wins!]
 +
end
 +
</scratchblocks>
 +
 
 +
* Checking that a value is within a given range
 +
 
 +
<scratchblocks>
 +
ask [Please rate my cookies from 1 to 10.] and wait
 +
repeat until <not <<(answer) < [1]> or <(answer) > [10]>>>
 +
    ask [Please rate my cookies from 1 to 10.] and wait
 +
end
 +
</scratchblocks>
 +
 
 +
== Workaround ==
 
{{main|List of Block Workarounds}}
 
{{main|List of Block Workarounds}}
 
The block can be replicated with the following code:
 
The block can be replicated with the following code:
  
[[File:Workaround_for_the_()_is_less_than_()_block.png]]
+
<scratchblocks><(b) > (a)></scratchblocks>
  
==Example Uses==
+
=== Less than or equal to ===
If a group must be arranged in size, this block can easily do the job.
+
Sometimes it is necessary to know if a value is less than or equal to another value, but there is no block to do so. This can be done as follows:
  
Some common uses for the '''() < ()''' block are below:
+
<scratchblocks><not <(a) > (b)>></scratchblocks>
  
*Arranging a set of numbers/letters
+
== See Also ==
*Evaluating numbers/letters
+
* [[() = () (block)]]
*Comparing different [[variable]]s (eg. comparing two characters' health in a game)
+
* [[() is greater than () (block)|() > ()]]
 +
* [[Numbers]]
  
==See Also==
 
*[[() = ()]]
 
*[[() is greater than () (block)|() > ()]]
 
 
{{Operators Blocks}}
 
{{Operators Blocks}}
 
[[Category:Operators Blocks]]
 
[[Category:Operators Blocks]]
 +
[[de:() ist kleiner () (Block)]]
 +
[[ja:() < () (ブロック)]]

Latest revision as of 04:21, 11 January 2020

The correct title of this article is () < () (block). The Scratch Wiki uses this different title because of technical restrictions.
() < ()
() < ()
Category Operators
Type Boolean

The () < () block is an Operators block and a Boolean block. The block reports true if the first value is less than the second value and false otherwise.

This block can compare both numbers and strings, which are ordered alphabetically. In Scratch 1.3 and previous versions, it only accepted numbers.

Example Uses

Some common uses for the () < () block are below:

set [i v] to [1]
repeat until <<(i) > (length of [scores v])> or <(item (i) of [scores v]) < (score)>>
    change [i v] by (1)
end
insert (score) at (i) of [scores v]
  • Evaluating numbers or letters
if <(score) < (5)> then
    say [Poor job.] for (1) secs
    stop [this script v]
end
if <(item (i) of [scores v]) < (10)> then
    say [Well done.] for (1) secs
    stop [this script v]
end
say [Great!] for (1) secs
if <(score 1) < (score 2)> then
    say [Player 2 wins!]
else
    say [Player 1 wins!]
end
  • Checking that a value is within a given range
ask [Please rate my cookies from 1 to 10.] and wait
repeat until <not <<(answer) < [1]> or <(answer) > [10]>>>
    ask [Please rate my cookies from 1 to 10.] and wait
end

Workaround

Main article: List of Block Workarounds

The block can be replicated with the following code:

<(b) > (a)>

Less than or equal to

Sometimes it is necessary to know if a value is less than or equal to another value, but there is no block to do so. This can be done as follows:

<not <(a) > (b)>>

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.