m
m (Sorry)
 
(25 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{Incorrect Title|() < ()}}
+
{{April Fools}}{{Incorrect Title|() < () (block)}}
{{Block
+
{{block
 
|name = () < ()
 
|name = () < ()
|image = File:2.0 ()_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 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, as well as numbers. In [[Scratch]], letters at the top of the alphabet (e.g. a, b, c) are worth less than letters at the end (e.g. x, y, z). In [[Scratch 1.3]] and previous versions, 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.
  
 
==Example Uses==
 
==Example Uses==
{{Expand}}
+
Some common uses for the () < () block are below:
If a group must be arranged in size, this block can easily do the job.
+
 
 +
* [[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
  
Some common uses for the () < () block are below:
+
<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
  
*Arranging a set of numbers/letters
+
<scratchblocks>
*Evaluating numbers/letters
+
ask [Please rate my cookies from 1 to 10.] and wait
*Comparing different [[variable]]s (eg. comparing two characters' health in a game)
+
repeat until <not <<(answer) < [1]> or <(answer) > [10]>>>
 +
    ask [Please rate my cookies from 1 to 10.] and wait
 +
end
 +
</scratchblocks>
  
==Workaround==
+
== 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>
<scratchblocks><not <<(a) > (b)> or <(a) = (b)>>></scratchblocks>
+
 
 +
=== 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:
 +
 
 +
<scratchblocks><not <(a) > (b)>></scratchblocks>
 +
 
 +
== See Also ==
 +
* [[() = () (block)]]
 +
* [[() 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)]]
 
[[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.