Basicprogramming(.org) > General questions and discussions

Dir Walk Challenge

(1/4) > >>

B+:

--- Quote ---Tomaaz
Full Member
***
 
Posts: 123
View Profile  Personal Message (Online)

Re: Notes on Script BASIC
« Reply #35 on: 22. September 2018, 17:48:49 »
Quote
OK. Here is another task. Recursively walk directory, find all .jpg files which names are integers, sort the names by numbers and print the result.

Ruby (one line):
Code:
puts Dir.glob("**/*").select{|a| File.extname(a) == ".jpg" and File.basename(a, ".jpg").to_i.to_s == File.basename(a, ".jpg")}.map {|a| File.basename(a, ".jpg").to_i}.sort

If you want to know what part of the code is responsible for what part of the task, I can explain it to you. It only looks cryptic. If you know basics of Ruby it's clear as
Code:
for x = 1 to 10 : print x : next x
in BASIC.  ;)

--- End quote ---

Tomaaz do you have sample screen shot of output. I am probably going to repeat a question about "map" but it might be solved by picture.

Also I assume it doesn't have to be .jpg extension or start with number maybe any base name condition is good.
I'd prefer to build something that actually might have some use for me and this sort of stuff is not but a .bas file starting with certain base names might be very useful. I mean I hate to be accused of playing around ALL of the time with my BASIC's.


@ Mike
The B of B+ mostly stands for Build as in B += .... But standing for Eternal Beginner is OK too, someone should keep the eternal flame alive.

Mike Lobanovsky:
B+,

Actually my remark was there to cut down a little that bitter taste the whole incident left in my mouth. :)

History spins in circles, and we've seen all this before on the old BP.org. But IIRC then the instigator was that narcissistic graphomaniac that used to call himself menn, or mennonite, or bestof, or something similar. It's sad to see other people stepping into his place on this newer forum board.

Tomaaz:

--- Quote from: B+ on September 23, 2018, 04:03:05 pm ---Tomaaz do you have sample screen shot of output. I am probably going to repeat a question about "map" but it might be solved by picture.

--- End quote ---

Output is just a bunch of numbers and it depends on what is in the directory you're running the script in.

ZXDunny:

--- Quote from: Mike Lobanovsky on September 24, 2018, 01:59:26 am ---B+,

Actually my remark was there to cut down a little that bitter taste the whole incident left in my mouth. :)

History spins in circles, and we've seen all this before on the old BP.org. But IIRC then the instigator was that narcissistic graphomaniac that used to call himself menn, or mennonite, or bestof, or something similar. It's sad to see other people stepping into his place on this newer forum board.

--- End quote ---

You mean the incident where John continued slagging off other BASIC interpreter authors and calling their hobbies and efforts "toys" and worthless pursuits as opposed to his "professional" BASIC interpreter which everyone should be using (either as a template for other languages or outright as the only tool in their box)? Where I decided I'd had enough of his bitching and sniping and called him out on it? And where he flounced out of the forum - as he has done before on previous boards - in righteous indignation?

That incident?

Because god forbid that anyone gets any enjoyment out of something they create for their own pleasure, yeah?

Mike Lobanovsky:
Your trying to troll me isn't going to lead you anywhere.

I said:
--- Quote ---then the instigator was that narcissistic graphomaniac that used to call himself menn
--- End quote ---
and I said:
--- Quote ---This is all I have to say regarding the topic, and as I have already said, I will abstain from any further fruitless discussions on it here or elsewhere.
--- End quote ---

Find yourself another target. I've seen enough of it on the old BP.org and am pretty much fed up with it since years.

Navigation

[0] Message Index

[#] Next page

Go to full version