Lowercase & Uppercase Chars

So, I decided to make a project that can convert characters to their lowercase/uppercase forms without using JavaScript. I already know that someone made something similar, but this is more effective.


CONVERT () TO ()

[scratchblocks]
(convert [world] to [lowercase v] :: operators)
[/scratchblocks]

In JavaScript:

[scratchblocks]
(call (JavaScript function \( [text]­@delInput@addInput \) \{ [return text.toLowerCase()] \} :: operators) with inputs: [Hello World!]­@delInput@addInput :: control)
[/scratchblocks]

Features:

  • Supports Latin Alphabet

[scratchblocks]
(convert [abcdefghijklmnopqrstuvwxyz] to [uppercase v] :: operators) // ABCDEFGHIJKLMNOPQRSTUVWXYZ
[/scratchblocks]

  • Supports Extended Latin Alphabet

[scratchblocks]
(convert [áéíóúýäëïöüñ] to [uppercase v] :: operators) // ÁÉÍÓÚÝÄËÏÖÜÑ
[/scratchblocks]

  • Supports many other alphabets

[scratchblocks]
(convert [αβγδεζηθικλμνξοπρστυφχψωабвгдеёжзийклмнопрстуфхцчшщъыьэюя] to [uppercase v] :: operators) // ...
[/scratchblocks]

Recommendations:

  • Use this:

[scratchblocks]
(convert [tExT] to [lowercase v] :: operators)
[/scratchblocks] instead of

[scratchblocks]
(convert (convert [tExT] to [lowercase v] :: operators) to [lowercase v] :: operators)
[/scratchblocks] for better performance.


IS () () ?

[scratchblocks]
<is [a] [lowercase v] :: operators>
[/scratchblocks]

Features:

  • There are 3 options: lowercase, uppercase and none (none means neither lowercase nor uppercase).

[scratchblocks]
<is [A] [lowercase v] :: operators> // false
[/scratchblocks]

Recommendations:

  • Use this if you want to verify each character of the text.

[scratchblocks]
(call ({script variables ((result) :: grey)­@addInput :: grey
set [result v] to (list­@addInput :: list)
warp{
for each ((item) :: list) in (split (text) by ( v) :: operators){
add <is (item) (type) ? :: operators> to (result)
}­@loopArrow :: list
} :: grey
report (result) :: control cap} input names: ((text) :: grey) ((type) :: grey)­@delInput@addInput :: ring grey) with inputs: [Hello, World!] [lowercase]­@delInput@addInput :: control)
[/scratchblocks]


Notes:
Only supports the first 1401 Unicode characters for better performance. Reply to me if you need anything.

(C) 2021 ScratchModification.

3 points here:


  • Why is there 2 topics?
  • Why did you add

? You can't copyright stuff on Snap!.

  • Nice project.

My Rating


★★★★★ Five stars! I like that this is JavaScript free. I've done this before as well, for a project.


Fun Fact:


Did you know:
Instead of using ScratchBlocks on the forums, you can use the feature "Script Pic..."? Just right-click a script and press "Script Pic..."!

Did you know:
There is another way to do this.

Script

(For lowercase)

Script

(For uppercase)


Source Code for this post
<big>3 points here:</big>
___
* Why is there 2 topics?
* Why did you add

[quote="scratchmodification, post:1, topic:9602"]
*(C) 2021 ScratchModification.*
[/quote]
? You can't copyright stuff on Snap<i>!</i>.
* Nice project.
___
<big>`My Rating`</big>
___
★★★★★ Five stars! I like that this is JavaScript free. I've done this before as well, for a project.
___
<big>Fun Fact:</big>
___
Did you know:
Instead of using ScratchBlocks on the forums, you can use the feature "Script Pic..."? Just right-click a script and press "Script Pic..."!

Did you know:
There is another way to do this. 
[details=Script]
![untitled script pic|464x500](upload://66rxvvZCmVa7tEfd09dERcnNk27.png)
[/details]
(For lowercase)

[details="Script"]
![untitled script pic (1)|454x500](upload://riqXcRo1yM9NHOBdZlETvH0t16Q.png)
[/details]
(For uppercase)

There's a much easier (and faster) way to do this...
[scratchblocks](map(<is[][lowercase v]?::operators>@addInput::grey ring)over(split[Hello, world!]by(letter v)::operators)::list)[/scratchblocks]

Accidently pressed Ctrl + Enter. I just deleted it.

Just to inform people I created it.

Yeah, I know about that feature. But I don't like using pictures.

It only supports Latin Alphabet.

(Warning: More than you probably wanted to know about this, coming up.)

Actually, anything you create, in any medium, is automatically copyright. Those copyright notices used to be required, but now they're just a convenient way to let people track down who owns a copyright.

If you want to let anyone do anything with your work, you can explicitly disclaim copyright with a notice along the lines of "I, joecooldoo, the author of this work, hereby disclaim copyright in it, placing it in the public domain."

You can have more or less restrictive licenses on things you write. Many works under copyright have very restrictive licenses, so you have to pay money just to see the work, and even then you aren't allowed to make a copy of it. (Hence the name "copyright.")

People who want to let people use their stuff often use a Creative Commons license, especially if the stuff isn't a computer program, for which other more specific licenses are more commonly used. There are several CC licenses; I think there are five possible Boolean conditions, but not all 25 combinations are possible.

The thing about Snap! is that it doesn't make sense to publish a project on our web site unless you want people to use it. If you don't publish it, of course you can keep it to yourself. The only thing that's non-obvious about publishing on the Snap! site is that, because we believe in remixing, we require the use of the CC-BY-NC-SA (or, if you prefer, CC-BY-SA) license.

I wonder if this requirement is not only for publishing on the main Snap! community site, but also for posting here on the forums? I guess, it is.

It's not really comparable because you don't remix forum comments! But you can quote them, so I guess that's kinda related.

But they can see your username in the forum post and the project...

Ok, is this a better way to do that?

[scratchblocks]
(call ((map (<is [] (type) ? :: operators>@addInput :: ring grey) over (split (text) by ( v) :: operators) :: list) input names: ((text) :: grey) ((type) :: grey)­@delInput@addInput :: ring grey) with inputs: [Hello, World!] [lowercase]­@delInput@addInput :: control)
[/scratchblocks]

Not better, per se, just different. I'd like to think the user would know which inputs to change already.

The first input is the text, for example: "Hello, World!".
The second one is the type (none, lowercase or uppercase).

I vote for "better." Using higher order functions makes code so much more readable! But you're focusing on a different question, which is how to parameterize a script. And the best answer to that is to make it a procedure (a custom block (yes, I know you know that, but other people may read this)) with inputs, rather than build the example into the script, whether via CALL or some other way.

I know...

What does "parameterize" mean?

By the way, I want to know if there could be some optimizations for my custom blocks.

"Turn constant examples into vary-able (that's what 'variable' means!) inputs." It's like turning 3×4² into 3×a².

Looking further at the code, I couldn't find any optimization issues that I would know how to fix, but I like how you directly use booleans in math functions (as in untitled script pic). I didn't think anyone else did that.

All I really did was replace the FOR loop with a MAP block...

Just to make this smaller:

[scratchblocks]
(if <(type) = [uppercase]> then <not <(unicode of (letter (i) of (_text)) :: operators) < (j)>> else <(unicode of (letter (i) of (_text)) :: operators) < (j)> :: control)
[/scratchblocks]

&^%^(*((!!!!!

Explicit loops are MUCH more readable to us muggles :slight_smile: